diff --git a/CHANGELOG.md b/CHANGELOG.md index 424dea2d..a3cc4093 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.8.6 (2017-12-12) + +Bugfixes: + + - fix [#80](https://github.com/typ0520/fastdex/issues/80) + ## 0.8.5 (2017-12-12) Bugfixes: @@ -88,7 +94,7 @@ Bugfixes: Bugfixes: - - fix [issues#59](https://github.com/typ0520/fastdex/issues/59) + - fix [#59](https://github.com/typ0520/fastdex/issues/59) ## 0.6.1 (2017-9-28) diff --git a/README.md b/README.md index 6abd458a..d203d6d6 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Android API 9(2.3)+ ; android-gradle-build 2.0.0+ } dependencies { - classpath 'com.github.typ0520:fastdex-gradle:0.8.5' + classpath 'com.github.typ0520:fastdex-gradle:0.8.6' } } ```` diff --git a/fastdex-gradle/src/main/groovy/fastdex/build/FastdexPlugin.groovy b/fastdex-gradle/src/main/groovy/fastdex/build/FastdexPlugin.groovy index 87981aac..1d9ce84f 100644 --- a/fastdex-gradle/src/main/groovy/fastdex/build/FastdexPlugin.groovy +++ b/fastdex-gradle/src/main/groovy/fastdex/build/FastdexPlugin.groovy @@ -331,6 +331,8 @@ class FastdexPlugin implements Plugin { fastdexVariant.hasJarMergingTask = true FastdexJarMergingTransform jarMergingTransform = new FastdexJarMergingTransform(transform,task.getStreamOutputFolder(),fastdexVariant) + fastdexVariant.jarMergerOutputFolder = task.getStreamOutputFolder() + Field field = ReflectUtils.getFieldByName(task.getClass(),'transform') field.setAccessible(true) field.set(task,jarMergingTransform) diff --git a/fastdex-gradle/src/main/groovy/fastdex/build/transform/FastdexDexTransform.groovy b/fastdex-gradle/src/main/groovy/fastdex/build/transform/FastdexDexTransform.groovy index 828ec6ce..7e4f4d38 100644 --- a/fastdex-gradle/src/main/groovy/fastdex/build/transform/FastdexDexTransform.groovy +++ b/fastdex-gradle/src/main/groovy/fastdex/build/transform/FastdexDexTransform.groovy @@ -9,9 +9,6 @@ import fastdex.build.util.Constants import fastdex.build.util.FastdexUtils import fastdex.build.util.GradleUtils import fastdex.build.variant.FastdexVariant -import com.google.common.collect.Lists -import com.android.build.api.transform.JarInput -import com.android.build.api.transform.TransformInput import fastdex.build.util.JarOperation /** @@ -101,25 +98,6 @@ class FastdexDexTransform extends TransformProxy { } } - - - /** - * 获取输出jar路径 - * @param invocation - * @return - */ - def getCombinedJarFile(TransformInvocation invocation) { - List jarInputs = Lists.newArrayList() - for (TransformInput input : invocation.getInputs()) { - jarInputs.addAll(input.getJarInputs()) - } - if (jarInputs.size() != 1) { - throw new RuntimeException("==fastdex jar input size is ${jarInputs.size()}, expected is 1") - } - File combinedJar = jarInputs.get(0).getFile() - return combinedJar - } - /** * 生成补丁jar包 * @param transformInvocation @@ -128,7 +106,7 @@ class FastdexDexTransform extends TransformProxy { def generatePatchJar(TransformInvocation transformInvocation) { if (fastdexVariant.hasJarMergingTask) { //如果开启了multidex,FastdexJarMergingTransform完成了jar merge的操作 - File patchJar = getCombinedJarFile(transformInvocation) + File patchJar = new File(fastdexVariant.jarMergerOutputFolder,Constants.PATCH_JAR) project.logger.error("==fastdex multiDex enabled use patch.jar: ${patchJar}") return patchJar } diff --git a/fastdex-gradle/src/main/groovy/fastdex/build/transform/FastdexJarMergingTransform.groovy b/fastdex-gradle/src/main/groovy/fastdex/build/transform/FastdexJarMergingTransform.groovy index ebf9afd3..fe982dcb 100644 --- a/fastdex-gradle/src/main/groovy/fastdex/build/transform/FastdexJarMergingTransform.groovy +++ b/fastdex-gradle/src/main/groovy/fastdex/build/transform/FastdexJarMergingTransform.groovy @@ -7,7 +7,6 @@ import fastdex.build.util.Constants import fastdex.build.util.GradleUtils import fastdex.build.util.JarOperation import fastdex.build.variant.FastdexVariant -import com.android.build.api.transform.Format import fastdex.common.utils.FileUtils /** @@ -24,8 +23,10 @@ class FastdexJarMergingTransform extends TransformProxy { void transform(TransformInvocation transformInvocation) throws TransformException, IOException, InterruptedException { if (fastdexVariant.hasDexCache) { if (fastdexVariant.projectSnapshoot.diffResultSet.isJavaFileChanged()) { + FileUtils.cleanDir(streamOutputFolder) + //补丁jar - File patchJar = getCombinedJarFile(transformInvocation) + File patchJar = new File(streamOutputFolder,Constants.PATCH_JAR) //生成补丁jar JarOperation.generatePatchJar(fastdexVariant,transformInvocation,patchJar) } @@ -45,19 +46,4 @@ class FastdexJarMergingTransform extends TransformProxy { } } } - - /** - * 获取输出jar路径 - * @param invocation - * @return - */ - def getCombinedJarFile(TransformInvocation invocation) { - def outputProvider = invocation.getOutputProvider() - - // all the output will be the same since the transform type is COMBINED. - // and format is SINGLE_JAR so output is a jar - File jarFile = outputProvider.getContentLocation("combined", base.getOutputTypes(), base.getScopes(), Format.JAR) - FileUtils.ensumeDir(jarFile.getParentFile()) - return jarFile - } } \ No newline at end of file diff --git a/fastdex-gradle/src/main/groovy/fastdex/build/variant/FastdexVariant.groovy b/fastdex-gradle/src/main/groovy/fastdex/build/variant/FastdexVariant.groovy index e4ebedec..66d9f2ee 100755 --- a/fastdex-gradle/src/main/groovy/fastdex/build/variant/FastdexVariant.groovy +++ b/fastdex-gradle/src/main/groovy/fastdex/build/variant/FastdexVariant.groovy @@ -35,6 +35,7 @@ class FastdexVariant { Set libraryDependencies File textSymbolOutputFile + File jarMergerOutputFolder File dexBuilderOutputFolder File dexMergerOutputFolder File preDexOutputFolder diff --git a/gradle.properties b/gradle.properties index 1a6f1c15..a4c1552b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,7 +20,7 @@ org.gradle.daemon=true groupId=com.github.typ0520 -version=0.8.5 +version=0.8.6 ANDROID_BUILD_MIN_SDK_VERSION=14 ANDROID_BUILD_TARGET_SDK_VERSION=22 diff --git a/sample/app/build.gradle b/sample/app/build.gradle index bde154f7..499b04fd 100644 --- a/sample/app/build.gradle +++ b/sample/app/build.gradle @@ -29,7 +29,7 @@ fastdex { dexMergeThreshold = 3 //是否仅hook debug - onlyHookDebug = true + onlyHookDebug = false } android { diff --git a/sample/app/src/main/java/fastdex/sample/MainActivity.java b/sample/app/src/main/java/fastdex/sample/MainActivity.java index fdbdb1a2..abc9c4fb 100644 --- a/sample/app/src/main/java/fastdex/sample/MainActivity.java +++ b/sample/app/src/main/java/fastdex/sample/MainActivity.java @@ -95,7 +95,7 @@ public void onClick(View view) { // sb.append("\n"); sb.append(getResources().getString(commonstr)); sb.append("\n"); - sb.append("11"); + sb.append("00"); Log.d(TAG,"sb: \n" + sb.toString()); Toast.makeText(this, sb.toString(),Toast.LENGTH_LONG).show(); diff --git a/sample/build.gradle b/sample/build.gradle index 0fa521e9..1fab0917 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -9,12 +9,12 @@ buildscript { maven { url 'https://maven.google.com' } } dependencies { - classpath 'com.android.tools.build:gradle:2.3.3' + classpath 'com.android.tools.build:gradle:3.0.1' //classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' classpath "me.tatarka:gradle-retrolambda:3.7.0" classpath 'com.jakewharton:butterknife-gradle-plugin:8.8.1' - classpath 'com.github.typ0520:fastdex-gradle:0.8.5' + classpath 'com.github.typ0520:fastdex-gradle:0.8.6' } }