Search in sources :

Example 1 with TransformTask

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

the class AwbProguradHook method getTransformTaskByTransformType.

private List<TransformTask> getTransformTaskByTransformType(AppVariantContext appVariantContext, Class<?> transformClass) {
    List<TransformTask> transformTasksList = Lists.newArrayList();
    VariantConfiguration config = appVariantContext.getVariantConfiguration();
    TaskCollection<TransformTask> transformTasks = appVariantContext.getProject().getTasks().withType(TransformTask.class);
    SortedMap<String, TransformTask> transformTaskSortedMap = transformTasks.getAsMap();
    String variantName = config.getFullName();
    for (String taskName : transformTaskSortedMap.keySet()) {
        TransformTask transformTask = transformTaskSortedMap.get(taskName);
        if (variantName.equals(transformTask.getVariantName())) {
            if (transformTask.getTransform().getClass().equals(transformClass)) {
                transformTasksList.add(transformTask);
            }
        }
    }
    return transformTasksList;
}
Also used : TransformTask(com.android.build.gradle.internal.pipeline.TransformTask) VariantConfiguration(com.android.builder.core.VariantConfiguration)

Example 2 with TransformTask

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

the class TransformReplacer method replaceProguardTransform.

public void replaceProguardTransform() {
    List<TransformTask> baseTransforms = TransformManager.findTransformTaskByTransformType(variantContext, ProGuardTransform.class);
    List<TransformTask> nextTransformTasks = TransformManager.findTransformTaskByTransformType(variantContext, DexArchiveBuilderTransform.class);
    for (TransformTask transformTask : baseTransforms) {
        AtlasProguardTransform newTransform = new AtlasProguardTransform(variantContext);
        newTransform.oldTransform = (ProGuardTransform) transformTask.getTransform();
        for (TransformTask nextTransformTask : nextTransformTasks) {
            if (nextTransformTask.getVariantName().equals(transformTask.getVariantName())) {
                newTransform.nextTransformTask = nextTransformTask;
            }
        }
        ReflectUtils.updateField(transformTask, "transform", newTransform);
    // 
    }
}
Also used : TransformTask(com.android.build.gradle.internal.pipeline.TransformTask)

Example 3 with TransformTask

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

the class TransformReplacer method replaceDexMerge.

public void replaceDexMerge(BaseVariantOutput vod) {
    List<TransformTask> list = TransformManager.findTransformTaskByTransformType(variantContext, DexMergerTransform.class);
    DexingType dexingType = variantContext.getScope().getDexingType();
    if (variantContext.getScope().getInstantRunBuildContext().isInInstantRunMode() && variantContext.getVariantConfiguration().getMinSdkVersion().getApiLevel() < 21) {
        dexingType = DexingType.LEGACY_MULTIDEX;
    }
    DexMergerTool dexMergerTool = variantContext.getScope().getDexMerger();
    int sdkVerision = variantContext.getScope().getMinSdkVersion().getFeatureLevel();
    boolean debug = variantContext.getScope().getVariantConfiguration().getBuildType().isDebuggable();
    ErrorReporter errorReporter = variantContext.getScope().getGlobalScope().getAndroidBuilder().getErrorReporter();
    for (TransformTask transformTask : list) {
        AtlasDexMergerTransform dexMergerTransform = new AtlasDexMergerTransform(variantContext.getAppVariantOutputContext(ApkDataUtils.get(vod)), dexingType, dexingType == DexingType.LEGACY_MULTIDEX ? variantContext.getProject().files(variantContext.getScope().getMainDexListFile()) : null, errorReporter, dexMergerTool, sdkVerision, debug);
        ReflectUtils.updateField(transformTask, "transform", dexMergerTransform);
    }
}
Also used : DexingType(com.android.builder.dexing.DexingType) ErrorReporter(com.android.builder.core.ErrorReporter) DexMergerTool(com.android.builder.dexing.DexMergerTool) TransformTask(com.android.build.gradle.internal.pipeline.TransformTask) AtlasDexMergerTransform(com.taobao.android.builder.tasks.transform.dex.AtlasDexMergerTransform)

Example 4 with TransformTask

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

the class TransformReplacer method replaceDataBindingMergeArtifactsTransform.

public void replaceDataBindingMergeArtifactsTransform() {
    List<TransformTask> list = TransformManager.findTransformTaskByTransformType(variantContext, DataBindingMergeArtifactsTransform.class);
    for (TransformTask transformTask : list) {
        File outFolder = new File(variantContext.getScope().getBuildFolderForDataBindingCompiler(), DataBindingBuilder.ARTIFACT_FILES_DIR_FROM_LIBS);
        AtlasDataBindingMergeArtifactsTransform dataBindingMergeArtifactsTransform = new AtlasDataBindingMergeArtifactsTransform(variantContext, Logging.getLogger(AtlasDataBindingMergeArtifactsTransform.class), outFolder);
        ReflectUtils.updateField(transformTask, "transform", dataBindingMergeArtifactsTransform);
    }
}
Also used : TransformTask(com.android.build.gradle.internal.pipeline.TransformTask) File(java.io.File)

Example 5 with TransformTask

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

the class TransformReplacer method replaceDesugarTransform.

public void replaceDesugarTransform(BaseVariantOutput vod) {
    List<TransformTask> baseTransforms = TransformManager.findTransformTaskByTransformType(variantContext, DesugarTransform.class);
    for (TransformTask transformTask : baseTransforms) {
        DesugarTransform transform = (DesugarTransform) transformTask.getTransform();
        AtlasDesugarTransform atlasDesugarTransform = new AtlasDesugarTransform(variantContext.getAppVariantOutputContext(ApkDataUtils.get(vod)), (Supplier<List<File>>) ReflectUtils.getField(transform, "androidJarClasspath"), (List) ReflectUtils.getField(transform, "compilationBootclasspath"), variantContext.getScope().getGlobalScope().getBuildCache(), (int) ReflectUtils.getField(transform, "minSdk"), (JavaProcessExecutor) ReflectUtils.getField(transform, "executor"), (boolean) ReflectUtils.getField(transform, "verbose"), (boolean) ReflectUtils.getField(transform, "enableGradleWorkers"), (Path) ReflectUtils.getField(transform, "tmpDir"));
        atlasDesugarTransform.oldTransform = transform;
        ReflectUtils.updateField(transformTask, "transform", atlasDesugarTransform);
    }
}
Also used : TransformTask(com.android.build.gradle.internal.pipeline.TransformTask) List(java.util.List)

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