use of com.android.build.gradle.tasks.MergeManifests in project atlas by alibaba.
the class PreProcessManifestTask method addAwbManifest2Merge.
private void addAwbManifest2Merge() {
AtlasExtension atlasExtension = appVariantContext.getAtlasExtension();
for (final BaseVariantOutputData vod : appVariantContext.getVariantData().getOutputs()) {
ManifestProcessorTask manifestProcessorTask = vod.manifestProcessorTask;
Set<String> notMergedArtifacts = Sets.newHashSet();
if (null != atlasExtension.getManifestOptions() && null != atlasExtension.getManifestOptions().getNotMergedBundles()) {
notMergedArtifacts = atlasExtension.getManifestOptions().getNotMergedBundles();
}
if (manifestProcessorTask instanceof MergeManifests) {
MergeManifests mergeManifests = (MergeManifests) manifestProcessorTask;
VariantScope variantScope = appVariantContext.getScope();
GradleVariantConfiguration config = variantScope.getVariantConfiguration();
AndroidDependencyTree dependencyTree = AtlasBuildContext.androidDependencyTrees.get(config.getFullName());
if (null == dependencyTree) {
throw new StopExecutionException("DependencyTree cannot be null!");
}
List<? extends AndroidLibrary> awbManifests = ManifestDependencyUtil.getManifestDependencies(dependencyTree.getAwbBundles(), notMergedArtifacts, getLogger());
for (AndroidLibrary manifest : awbManifests) {
getLogger().info("[MTLPlugin]Add manifest:" + manifest.getName() + ",path is:" + manifest.getManifest().getAbsolutePath());
}
//FIXME 不加这一步,每次的getibraries 都会从mapping里去重新计算
mergeManifests.setLibraries(mergeManifests.getLibraries());
mergeManifests.getLibraries().addAll(awbManifests);
}
}
}
Aggregations