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