use of com.android.tools.build.bundletool.mergers.SameTargetingMerger in project bundletool by google.
the class ModuleSplitter method runSplitters.
private ImmutableList<ModuleSplit> runSplitters() {
if (targetsOnlyPreL(module)) {
throw CommandExecutionException.builder().withInternalMessage("Cannot split module '%s' because it does not target devices on Android L or above.", module.getName()).build();
}
ImmutableList.Builder<ModuleSplit> splits = ImmutableList.builder();
// Resources splits.
SplittingPipeline resourcesPipeline = createResourcesSplittingPipeline();
splits.addAll(resourcesPipeline.split(ModuleSplit.forResources(module, variantTargeting)));
// Native libraries splits.
SplittingPipeline nativePipeline = createNativeLibrariesSplittingPipeline();
splits.addAll(nativePipeline.split(ModuleSplit.forNativeLibraries(module, variantTargeting)));
// Assets splits.
SplittingPipeline assetsPipeline = createAssetsSplittingPipeline();
splits.addAll(assetsPipeline.split(ModuleSplit.forAssets(module, variantTargeting)));
// Dex Files.
SplittingPipeline dexPipeline = createDexSplittingPipeline();
splits.addAll(dexPipeline.split(ModuleSplit.forDex(module, variantTargeting)));
// Other files.
splits.add(ModuleSplit.forRoot(module, variantTargeting));
// Merging and making a master split.
ImmutableList<ModuleSplit> mergedSplits = new SameTargetingMerger().merge(applyMasterManifestMutators(splits.build()));
// Check that we have only one split with default targeting - the master split.
ImmutableList<ModuleSplit> defaultTargetingSplits = mergedSplits.stream().filter(split -> split.getApkTargeting().equals(ApkTargeting.getDefaultInstance())).collect(toImmutableList());
checkState(defaultTargetingSplits.size() == 1, "Expected one split with default targeting.");
return mergedSplits;
}
use of com.android.tools.build.bundletool.mergers.SameTargetingMerger in project bundletool by google.
the class ModuleSplitterForShards method generateSplits.
/**
* Generates a flat list of splits from a bundle module.
*/
public ImmutableList<ModuleSplit> generateSplits(BundleModule module, ImmutableSet<OptimizationDimension> shardingDimensions) {
ImmutableList.Builder<ModuleSplit> rawSplits = ImmutableList.builder();
// Native libraries splits.
SplittingPipeline nativePipeline = createNativeLibrariesSplittingPipeline(shardingDimensions);
rawSplits.addAll(nativePipeline.split(ModuleSplit.forNativeLibraries(module)));
// Resources splits.
SplittingPipeline resourcesPipeline = createResourcesSplittingPipeline(shardingDimensions);
rawSplits.addAll(resourcesPipeline.split(ModuleSplit.forResources(module)));
// Apex images splits.
SplittingPipeline apexPipeline = createApexImagesSplittingPipeline();
rawSplits.addAll(apexPipeline.split(ModuleSplit.forApex(module)));
// Assets splits.
SplittingPipeline assetsPipeline = createAssetsSplittingPipeline(shardingDimensions);
rawSplits.addAll(assetsPipeline.split(ModuleSplit.forAssets(module)));
// Other files.
rawSplits.add(ModuleSplit.forDex(module));
rawSplits.add(ModuleSplit.forRoot(module));
ImmutableList<ModuleSplit> unmergedSplits = rawSplits.build();
// Strip assets for some dimensions (texture compression format).
ImmutableList<ModuleSplit> unmergedStrippedSplits = stripAssetsWithTargeting(unmergedSplits);
// Merge splits with the same targeting and make a single master split.
ImmutableList<ModuleSplit> mergedSplits = new SameTargetingMerger().merge(unmergedStrippedSplits);
// Remove the splitName from any standalone apks, as these are only used for instant apps (L+).
mergedSplits = mergedSplits.stream().map(ModuleSplit::removeSplitName).collect(toImmutableList());
// Check that we have only one master split.
long masterSplitCount = mergedSplits.stream().filter(ModuleSplit::isMasterSplit).count();
checkState(masterSplitCount == 1, "Expected one master split, got %s.", masterSplitCount);
return mergedSplits;
}
Aggregations