Search in sources :

Example 16 with TransformTask

use of com.android.build.gradle.internal.pipeline.TransformTask in project atlas by alibaba.

the class TransformReplacer method replaceShrinkResourcesTransform.

public void replaceShrinkResourcesTransform() {
    File shrinkerOutput = FileUtils.join(variantContext.getScope().getGlobalScope().getIntermediatesDir(), "res_stripped", variantContext.getScope().getVariantConfiguration().getDirName());
    List<TransformTask> baseTransforms = TransformManager.findTransformTaskByTransformType(variantContext, ShrinkResourcesTransform.class);
    for (TransformTask transform : baseTransforms) {
        ShrinkResourcesTransform oldTransform = (ShrinkResourcesTransform) transform.getTransform();
        ResourcesShrinker resourcesShrinker = new ResourcesShrinker(oldTransform, variantContext.getVariantData(), variantContext.getScope().getOutput(TaskOutputHolder.TaskOutputType.PROCESSED_RES), shrinkerOutput, AaptGeneration.fromProjectOptions(variantContext.getScope().getGlobalScope().getProjectOptions()), variantContext.getScope().getOutput(TaskOutputHolder.TaskOutputType.SPLIT_LIST), variantContext.getProject().getLogger(), variantContext);
        ReflectUtils.updateField(transform, "transform", resourcesShrinker);
    }
}
Also used : TransformTask(com.android.build.gradle.internal.pipeline.TransformTask) File(java.io.File)

Example 17 with TransformTask

use of com.android.build.gradle.internal.pipeline.TransformTask 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)

Example 18 with TransformTask

use of com.android.build.gradle.internal.pipeline.TransformTask in project atlas by alibaba.

the class MtlTransformInjector method injectTasks.

public void injectTasks(List<MtlTransformContext> mtlTaskContexts) {
    for (final Object vod : appVariantContext.getVariantOutputData()) {
        for (MtlTransformContext mtlTransformContext : mtlTaskContexts) {
            TransformTask transformTask = findTransformTask(mtlTransformContext);
            TransformTask injectedTask = appVariantContext.getInjectTransformManager().addInjectTransformBeforeTransform(transformTask.getTransform().getClass(), TransformManager.createTransform(appVariantContext, mtlTransformContext.getTransformTask(), (BaseVariantOutput) vod), appVariantContext.getScope());
            injectedTask.dependsOn(appVariantContext.getVariantData().compileTask);
        }
    }
}
Also used : BaseVariantOutput(com.android.build.gradle.api.BaseVariantOutput) TransformTask(com.android.build.gradle.internal.pipeline.TransformTask)

Aggregations

TransformTask (com.android.build.gradle.internal.pipeline.TransformTask)18 File (java.io.File)4 List (java.util.List)3 BaseVariantOutput (com.android.build.gradle.api.BaseVariantOutput)2 ExtraModelInfo (com.android.build.gradle.internal.ExtraModelInfo)2 GradleJavaProcessExecutor (com.android.build.gradle.internal.process.GradleJavaProcessExecutor)2 VariantScope (com.android.build.gradle.internal.scope.VariantScope)2 DefaultDexOptions (com.android.builder.core.DefaultDexOptions)2 VariantConfiguration (com.android.builder.core.VariantConfiguration)2 DexingType (com.android.builder.dexing.DexingType)2 AtlasMultiDexListTransform (com.taobao.android.builder.tasks.transform.dex.AtlasMultiDexListTransform)2 IOException (java.io.IOException)2 Task (org.gradle.api.Task)2 DataBindingBuilder (android.databinding.tool.DataBindingBuilder)1 QualifiedContent (com.android.build.api.transform.QualifiedContent)1 Transform (com.android.build.api.transform.Transform)1 LibraryVariantOutput (com.android.build.gradle.api.LibraryVariantOutput)1 LibraryCache (com.android.build.gradle.internal.LibraryCache)1 SdkHandler (com.android.build.gradle.internal.SdkHandler)1 TaskContainerAdaptor (com.android.build.gradle.internal.TaskContainerAdaptor)1