use of com.taobao.android.builder.tools.multidex.FastMultiDexer in project atlas by alibaba.
the class DexByteCodeConverterHook method generateMainDexList.
private void generateMainDexList(File mainDexListFile) {
Collection<File> inputs = AtlasBuildContext.atlasMainDexHelperMap.get(variantContext.getVariantName()).getAllMainDexJars();
inputs.addAll(AtlasBuildContext.atlasMainDexHelperMap.get(variantContext.getVariantName()).getInputDirs());
FastMultiDexer fastMultiDexer = (FastMultiDexer) AtlasBuildContext.androidBuilderMap.get(variantContext.getScope().getGlobalScope().getProject()).multiDexer;
if (fastMultiDexer == null) {
fastMultiDexer = new FastMultiDexer((AppVariantContext) variantContext);
}
Collection<File> files = null;
try {
files = fastMultiDexer.repackageJarList(inputs, mainDexListFile, variantContext.getScope().getVariantData().getName().toLowerCase().endsWith("release"));
} catch (IOException e) {
e.printStackTrace();
}
if (files != null && files.size() > 0) {
AtlasBuildContext.atlasMainDexHelperMap.get(variantContext.getVariantName()).addAllMainDexJars(files);
}
}
use of com.taobao.android.builder.tools.multidex.FastMultiDexer in project atlas by alibaba.
the class AtlasMultiDexListTransform method transform.
public void transform(@NonNull TransformInvocation transformInvocation) throws TransformException, InterruptedException, IOException {
if (mainDexListFile.exists() && !variantScope.getVariantData().getName().toLowerCase().endsWith("release")) {
return;
}
LoggingManager loggingManager = transformInvocation.getContext().getLogging();
loggingManager.captureStandardOutput(LogLevel.INFO);
loggingManager.captureStandardError(LogLevel.WARN);
Collection<File> inputs = AtlasBuildContext.atlasMainDexHelperMap.get(variantScope.getFullVariantName()).getAllMainDexJars();
inputs.addAll(AtlasBuildContext.atlasMainDexHelperMap.get(variantScope.getFullVariantName()).getInputDirs());
if (AtlasBuildContext.androidBuilderMap.get(variantScope.getGlobalScope().getProject()) == null) {
super.transform(transformInvocation);
} else if (AtlasBuildContext.androidBuilderMap.get(variantScope.getGlobalScope().getProject()).multiDexer == null) {
super.transform(transformInvocation);
}
FastMultiDexer fastMultiDexer = (FastMultiDexer) AtlasBuildContext.androidBuilderMap.get(variantScope.getGlobalScope().getProject()).multiDexer;
Collection<File> files = fastMultiDexer.repackageJarList(inputs, mainDexListFile, variantScope.getVariantData().getName().toLowerCase().endsWith("release"));
if (files != null && files.size() > 0) {
AtlasBuildContext.atlasMainDexHelperMap.get(variantScope.getFullVariantName()).addAllMainDexJars(files);
}
}
use of com.taobao.android.builder.tools.multidex.FastMultiDexer in project atlas by alibaba.
the class TransformReplacer method replaceMultiDexListTransform.
public void replaceMultiDexListTransform() {
List<TransformTask> list = null;
FastMultiDexer fastMultiDexer = new FastMultiDexer(variantContext);
if (usingIncrementalDexing(variantContext.getScope())) {
list = TransformManager.findTransformTaskByTransformType(variantContext, MainDexListTransform.class);
} else {
list = TransformManager.findTransformTaskByTransformType(variantContext, MultiDexTransform.class);
}
if (list.size() > 0 && fastMultiDexer.isFastMultiDexEnabled()) {
com.android.build.gradle.internal.dsl.DexOptions dexOptions = variantContext.getScope().getGlobalScope().getExtension().getDexOptions();
AtlasMultiDexListTransform atlasMultiDexListTransform = new AtlasMultiDexListTransform(variantContext.getScope(), dexOptions);
for (TransformTask transformTask : list) {
ReflectUtils.updateField(transformTask, "transform", atlasMultiDexListTransform);
transformTask.doFirst(task -> AtlasBuildContext.androidBuilderMap.get(task.getProject()).multiDexer = (AtlasBuilder.MultiDexer) fastMultiDexer);
transformTask.doLast(task -> AtlasBuildContext.androidBuilderMap.get(task.getProject()).multiDexer = null);
}
}
}
use of com.taobao.android.builder.tools.multidex.FastMultiDexer in project atlas by alibaba.
the class TransformReplacer method generateMainDexList.
private void generateMainDexList(VariantScope variantScope) {
File mainDexListFile = variantScope.getMainDexListFile();
Collection<File> inputs = AtlasBuildContext.atlasMainDexHelperMap.get(variantScope.getFullVariantName()).getAllMainDexJars();
inputs.addAll(AtlasBuildContext.atlasMainDexHelperMap.get(variantScope.getFullVariantName()).getInputDirs());
FastMultiDexer fastMultiDexer = new FastMultiDexer(variantContext);
Collection<File> files = null;
try {
files = fastMultiDexer.repackageJarList(inputs, mainDexListFile, variantScope.getVariantData().getName().toLowerCase().endsWith("release"));
} catch (IOException e) {
e.printStackTrace();
}
if (files != null && files.size() > 0) {
AtlasBuildContext.atlasMainDexHelperMap.get(variantScope.getFullVariantName()).addAllMainDexJars(files);
}
}
Aggregations