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;
}
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);
//
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations