Skip to content

Commit

Permalink
fix-#80
Browse files Browse the repository at this point in the history
  • Loading branch information
typ0520 committed Dec 12, 2017
1 parent f72e460 commit 9ef1fe2
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 47 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}
````
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ class FastdexPlugin implements Plugin<Project> {
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down Expand Up @@ -101,25 +98,6 @@ class FastdexDexTransform extends TransformProxy {
}
}



/**
* 获取输出jar路径
* @param invocation
* @return
*/
def getCombinedJarFile(TransformInvocation invocation) {
List<JarInput> 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
Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand All @@ -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)
}
Expand All @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class FastdexVariant {
Set<LibDependency> libraryDependencies

File textSymbolOutputFile
File jarMergerOutputFolder
File dexBuilderOutputFolder
File dexMergerOutputFolder
File preDexOutputFolder
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sample/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fastdex {
dexMergeThreshold = 3

//是否仅hook debug
onlyHookDebug = true
onlyHookDebug = false
}

android {
Expand Down
2 changes: 1 addition & 1 deletion sample/app/src/main/java/fastdex/sample/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}

Expand Down

0 comments on commit 9ef1fe2

Please sign in to comment.