Search in sources :

Example 1 with JarMergerWithOverride

use of com.taobao.android.builder.tools.jarmerge.JarMergerWithOverride in project atlas by alibaba.

the class DexBuildTask method doFullTaskAction.

@TaskAction
public void doFullTaskAction() throws IOException {
    classJar = getClassJar();
    dependencyJars = getDependencyJars();
    File mergeJar = new File(classJar.getParentFile(), "merge.jar");
    JarMergerWithOverride jarMergerWithOverride = new JarMergerWithOverride(mergeJar);
    jarMergerWithOverride.addJar(classJar);
    for (File file : dependencyJars) {
        jarMergerWithOverride.addJar(file);
    }
    jarMergerWithOverride.close();
    ClassPool classPool = initClassPool(mergeJar);
    String jarFileName = classJar.getName();
    String outFileName = FilenameUtils.getBaseName(jarFileName) + "-inject.jar";
    File outPutJar = new File(classJar.getParentFile(), outFileName);
    CodeInjectByJavassist.inject(classPool, mergeJar, outPutJar, new InjectParam());
    getOutputDexFile().getParentFile().mkdirs();
    outputDexFile = DexBuilderUtils.buildDexInJvm(outPutJar, getOutputDexFile(), new ArrayList<String>());
}
Also used : JarMergerWithOverride(com.taobao.android.builder.tools.jarmerge.JarMergerWithOverride) ClassPool(javassist.ClassPool) ArrayList(java.util.ArrayList) File(java.io.File) InjectParam(com.taobao.android.builder.tools.classinject.InjectParam) MtlBaseTaskAction(com.taobao.android.builder.tasks.manager.MtlBaseTaskAction)

Aggregations

MtlBaseTaskAction (com.taobao.android.builder.tasks.manager.MtlBaseTaskAction)1 InjectParam (com.taobao.android.builder.tools.classinject.InjectParam)1 JarMergerWithOverride (com.taobao.android.builder.tools.jarmerge.JarMergerWithOverride)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 ClassPool (javassist.ClassPool)1