Skip to content

Commit 3a51815

Browse files
committed
fix amigo-lib not found
1 parent 54ca22e commit 3a51815

File tree

7 files changed

+42
-5
lines changed

7 files changed

+42
-5
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ buildscript {
2222
}
2323
2424
dependencies {
25-
classpath 'me.ele:amigo:0.6.7'
25+
classpath 'me.ele:amigo:0.6.8'
2626
}
2727
}
2828
```

README_zh.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ buildscript {
2121
}
2222
2323
dependencies {
24-
classpath 'me.ele:amigo:0.6.7'
24+
classpath 'me.ele:amigo:0.6.8'
2525
}
2626
}
2727
```

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
jcenter()
99
}
1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:2.2.3'
11+
classpath 'com.android.tools.build:gradle:2.3.0'
1212
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
1313
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
1414
}

buildSrc/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ dependencies {
2121

2222
compile fileTree(include: ['*.jar'], dir: 'libs')
2323
compile 'com.android.tools.build:gradle:2.2.3'
24+
compile 'net.lingala.zip4j:zip4j:1.3.2'
2425
}
2526

2627
def GROUP = 'me.ele'

buildSrc/src/main/groovy/me/ele/amigo/AmigoPlugin.groovy

+36
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.android.build.gradle.api.BaseVariantOutput
55
import groovy.io.FileType
66
import groovy.xml.QName
77
import groovy.xml.XmlUtil
8+
import net.lingala.zip4j.core.ZipFile
89
import org.gradle.api.Plugin
910
import org.gradle.api.Project
1011
import org.gradle.api.Task
@@ -137,18 +138,44 @@ class AmigoPlugin implements Plugin<Project> {
137138
}
138139
}
139140

141+
140142
void collectMultiDexInfo(Project project, ApkVariant variant) {
141143
if (!hasProguard(project, variant)) {
142144
File dir = new File("${project.buildDir}/intermediates/exploded-aar/me.ele/amigo-lib")
143145
JarFile jarFile
146+
File localCacheFile
144147
if (dir.exists()) {
145148
dir.eachFileRecurse(FileType.FILES) { File file ->
146149
if (file.name == 'classes.jar') {
147150
jarFile = new JarFile(file)
148151
return
149152
}
150153
}
154+
} else {
155+
String version = ""
156+
Configuration configuration = project.configurations.getByName('compile')
157+
configuration.allDependencies.all { Dependency dependency ->
158+
if (dependency.group == 'me.ele' && dependency.name == 'amigo-lib') {
159+
version = dependency.version
160+
}
161+
}
162+
String amigoCacheDir = "${project.gradle.gradleUserHomeDir}/caches/modules-2/files-2.1/me.ele/amigo-lib/${version}"
163+
File aarFile
164+
new File(amigoCacheDir).eachFileRecurse(FileType.FILES) { File file ->
165+
if (file.name.endsWith('.aar')) {
166+
aarFile = file
167+
return
168+
}
169+
}
170+
171+
localCacheFile = new File("${amigoCacheDir}/classes.jar")
172+
173+
ZipFile zipFile = new ZipFile(aarFile.absolutePath)
174+
zipFile.extractFile("classes.jar", amigoCacheDir)
175+
176+
jarFile = new JarFile(localCacheFile)
151177
}
178+
152179
Enumeration<JarEntry> enumeration = jarFile.entries()
153180
while (enumeration.hasMoreElements()) {
154181
JarEntry entry = enumeration.nextElement()
@@ -157,6 +184,11 @@ class AmigoPlugin implements Plugin<Project> {
157184
}
158185
content += "\n"
159186
content += "me/ele/amigo/acd.class"
187+
188+
if (localCacheFile != null) {
189+
localCacheFile.delete();
190+
}
191+
160192
return
161193
}
162194

@@ -206,3 +238,7 @@ class AmigoPlugin implements Plugin<Project> {
206238
}
207239

208240
}
241+
242+
243+
244+

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
# This option should only be used with decoupled projects. More details, visit
1717
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1818
# org.gradle.parallel=true
19-
VERSION=0.6.7
19+
VERSION=0.6.8

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.4-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

0 commit comments

Comments
 (0)