Search in sources :

Example 1 with VariantConfiguration

use of com.android.builder.core.VariantConfiguration 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 VariantConfiguration

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

the class TransformManager method findTransformTaskByTransformType.

public static List<TransformTask> findTransformTaskByTransformType(VariantContext 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 == transformTask.getVariantName()) {
            if (transformTask.getTransform().getClass() == transformClass) {
                transformTasksList.add(transformTask);
            }
        }
    }
    return transformTasksList;
}
Also used : TransformTask(com.android.build.gradle.internal.pipeline.TransformTask) VariantConfiguration(com.android.builder.core.VariantConfiguration)

Example 3 with VariantConfiguration

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

the class MergeAwbAssetConfigAction method execute.

@Override
public void execute(MergeSourceSetFolders task) {
    final VariantScope scope = variantContext.getScope();
    BaseVariantData<? extends BaseVariantOutputData> variantData = scope.getVariantData();
    final VariantConfiguration variantConfig = variantData.getVariantConfiguration();
    task.setAndroidBuilder(scope.getGlobalScope().getAndroidBuilder());
    task.setVariantName(variantConfig.getFullName());
    task.setIncrementalFolder(scope.getIncrementalDir(getName()));
    ConventionMappingHelper.map(task, "inputDirectorySets", new Callable<List<AssetSet>>() {

        @Override
        public List<AssetSet> call() throws Exception {
            List<AssetSet> assetSets = Lists.newArrayList();
            List<? extends AndroidLibrary> bundleDeps = awbBundle.getLibraryDependencies();
            // the list of dependency must be reversed to use the right overlay order.
            for (int n = bundleDeps.size() - 1; n >= 0; n--) {
                AndroidLibrary dependency = bundleDeps.get(n);
                File assetFolder = dependency.getAssetsFolder();
                if (assetFolder.isDirectory()) {
                    AssetSet assetSet = new AssetSet(dependency.getFolder().getName());
                    assetSet.addSource(assetFolder);
                    assetSets.add(assetSet);
                }
            }
            File awbAssetFolder = awbBundle.getAssetsFolder();
            if (awbAssetFolder.isDirectory()) {
                AssetSet awbAssetSet = new AssetSet(awbBundle.getFolder().getName());
                awbAssetSet.addSource(awbAssetFolder);
                assetSets.add(awbAssetSet);
            }
            return assetSets;
        }
    });
    ConventionMappingHelper.map(task, "outputDir", new Callable<File>() {

        @Override
        public File call() throws Exception {
            GlobalScope globalScope = scope.getGlobalScope();
            return variantContext.getMergeAssets(awbBundle);
        }
    });
//        if (variantContext instanceof AppVariantContext) {
//            AppVariantContext appVariantContext = (AppVariantContext) variantContext;
//            appVariantContext.getAwbMergeAssetTasks().put(awbBundle.getName(), task);
//        }
}
Also used : GlobalScope(com.android.build.gradle.internal.scope.GlobalScope) VariantScope(com.android.build.gradle.internal.scope.VariantScope) AndroidLibrary(com.android.builder.model.AndroidLibrary) AssetSet(com.android.ide.common.res2.AssetSet) List(java.util.List) File(java.io.File) VariantConfiguration(com.android.builder.core.VariantConfiguration)

Aggregations

VariantConfiguration (com.android.builder.core.VariantConfiguration)3 TransformTask (com.android.build.gradle.internal.pipeline.TransformTask)2 GlobalScope (com.android.build.gradle.internal.scope.GlobalScope)1 VariantScope (com.android.build.gradle.internal.scope.VariantScope)1 AndroidLibrary (com.android.builder.model.AndroidLibrary)1 AssetSet (com.android.ide.common.res2.AssetSet)1 File (java.io.File)1 List (java.util.List)1