Search in sources :

Example 1 with AssetSet

use of com.android.ide.common.res2.AssetSet 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

GlobalScope (com.android.build.gradle.internal.scope.GlobalScope)1 VariantScope (com.android.build.gradle.internal.scope.VariantScope)1 VariantConfiguration (com.android.builder.core.VariantConfiguration)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