Search in sources :

Example 1 with DefaultDexOptions

use of com.android.builder.core.DefaultDexOptions in project atlas by alibaba.

the class TransformReplacer method replaceDexTransform.

public void replaceDexTransform(AppVariantContext appVariantContext, BaseVariantOutput vod) {
    List<TransformTask> baseTransforms = TransformManager.findTransformTaskByTransformType(variantContext, DexTransform.class);
    DefaultDexOptions dexOptions = appVariantContext.getAppExtension().getDexOptions();
    DexingType dexingType = appVariantContext.getScope().getDexingType();
    DexByteCodeConverterHook dexByteCodeConverterHook = new DexByteCodeConverterHook(variantContext, variantContext.getAppVariantOutputContext(ApkDataUtils.get(vod)), LoggerWrapper.getLogger(DexByteCodeConverterHook.class), appVariantContext.getScope().getGlobalScope().getAndroidBuilder().getTargetInfo(), new GradleJavaProcessExecutor(appVariantContext.getProject()), appVariantContext.getProject().getLogger().isEnabled(LogLevel.INFO), new ExtraModelInfo(appVariantContext.getScope().getGlobalScope().getProjectOptions(), appVariantContext.getProject().getLogger()));
    for (TransformTask transformTask : baseTransforms) {
        DexTransform newTransform = new DexTransform(dexOptions, dexingType, false, appVariantContext.getProject().files(variantContext.getScope().getMainDexListFile()), verifyNotNull(appVariantContext.getScope().getGlobalScope().getAndroidBuilder().getTargetInfo(), "Target Info not set."), dexByteCodeConverterHook, appVariantContext.getScope().getGlobalScope().getAndroidBuilder().getErrorReporter(), variantContext.getScope().getMinSdkVersion().getFeatureLevel());
        ReflectUtils.updateField(transformTask, "transform", newTransform);
    }
}
Also used : DexingType(com.android.builder.dexing.DexingType) ExtraModelInfo(com.android.build.gradle.internal.ExtraModelInfo) DexByteCodeConverterHook(com.taobao.android.builder.hook.dex.DexByteCodeConverterHook) TransformTask(com.android.build.gradle.internal.pipeline.TransformTask) DefaultDexOptions(com.android.builder.core.DefaultDexOptions) GradleJavaProcessExecutor(com.android.build.gradle.internal.process.GradleJavaProcessExecutor)

Example 2 with DefaultDexOptions

use of com.android.builder.core.DefaultDexOptions in project atlas by alibaba.

the class TransformReplacer method replaceDexArchiveBuilderTransform.

public void replaceDexArchiveBuilderTransform(BaseVariantOutput vod) {
    List<TransformTask> list = TransformManager.findTransformTaskByTransformType(variantContext, DexArchiveBuilderTransform.class);
    DefaultDexOptions dexOptions = variantContext.getAppExtension().getDexOptions();
    boolean minified = variantContext.getScope().getCodeShrinker() != null;
    ProjectOptions projectOptions = variantContext.getScope().getGlobalScope().getProjectOptions();
    FileCache userLevelCache = getUserDexCache(minified, dexOptions.getPreDexLibraries());
    for (TransformTask transformTask : list) {
        AtlasDexArchiveBuilderTransform atlasDexArchiveBuilderTransform = new AtlasDexArchiveBuilderTransform(variantContext, vod, dexOptions, variantContext.getScope().getGlobalScope().getAndroidBuilder().getErrorReporter(), userLevelCache, variantContext.getScope().getMinSdkVersion().getFeatureLevel(), variantContext.getScope().getDexer(), projectOptions.get(BooleanOption.ENABLE_GRADLE_WORKERS), projectOptions.get(IntegerOption.DEXING_READ_BUFFER_SIZE), projectOptions.get(IntegerOption.DEXING_WRITE_BUFFER_SIZE), variantContext.getScope().getVariantConfiguration().getBuildType().isDebuggable());
        atlasDexArchiveBuilderTransform.setTransformTask(transformTask);
        ReflectUtils.updateField(transformTask, "transform", atlasDexArchiveBuilderTransform);
        if (variantContext.getScope().getInstantRunBuildContext().isInInstantRunMode() && variantContext.getVariantConfiguration().getMinSdkVersion().getApiLevel() < 21) {
            transformTask.doLast(task -> {
                task.getLogger().info("generate maindexList......");
                generateMainDexList(variantContext.getScope());
            });
        }
    }
}
Also used : AtlasDexArchiveBuilderTransform(com.taobao.android.builder.tasks.transform.dex.AtlasDexArchiveBuilderTransform) TransformTask(com.android.build.gradle.internal.pipeline.TransformTask) DefaultDexOptions(com.android.builder.core.DefaultDexOptions) ProjectOptions(com.android.build.gradle.options.ProjectOptions) FileCache(com.android.builder.utils.FileCache)

Aggregations

TransformTask (com.android.build.gradle.internal.pipeline.TransformTask)2 DefaultDexOptions (com.android.builder.core.DefaultDexOptions)2 ExtraModelInfo (com.android.build.gradle.internal.ExtraModelInfo)1 GradleJavaProcessExecutor (com.android.build.gradle.internal.process.GradleJavaProcessExecutor)1 ProjectOptions (com.android.build.gradle.options.ProjectOptions)1 DexingType (com.android.builder.dexing.DexingType)1 FileCache (com.android.builder.utils.FileCache)1 DexByteCodeConverterHook (com.taobao.android.builder.hook.dex.DexByteCodeConverterHook)1 AtlasDexArchiveBuilderTransform (com.taobao.android.builder.tasks.transform.dex.AtlasDexArchiveBuilderTransform)1