use of com.android.tools.build.bundletool.model.ModuleEntry in project bundletool by google.
the class ModuleSplitterTest method masterSplit_hasAllOtherApkComponents.
@Test
public void masterSplit_hasAllOtherApkComponents() throws Exception {
BundleModule testModule = new BundleModuleBuilder("testModule").setManifest(androidManifest("com.test.app")).addFile("assets/some_asset.txt").addFile("dex/classes.dex").addFile("root/some_other_file.txt").build();
ImmutableList<ModuleSplit> splits = createAbiAndDensitySplitter(testModule).splitModule();
assertThat(splits.stream().map(ModuleSplit::getSplitType).distinct().collect(toImmutableSet())).containsExactly(SplitType.SPLIT);
assertThat(splits.stream().map(ModuleSplit::getVariantTargeting).distinct().collect(toImmutableSet())).containsExactly(lPlusVariantTargeting());
// the example has nothing to split on.
assertThat(splits).hasSize(1);
ModuleSplit masterSplit = splits.get(0);
assertThat(masterSplit.getApkTargeting()).isEqualTo(DEFAULT_MASTER_SPLIT_SDK_TARGETING);
assertThat(masterSplit.isMasterSplit()).isTrue();
ImmutableSet<String> actualFiles = masterSplit.getEntries().stream().map(ModuleEntry::getPath).map(ZipPath::toString).collect(toImmutableSet());
ImmutableSet<String> expectedFiles = ImmutableSet.of("dex/classes.dex", "assets/some_asset.txt", "root/some_other_file.txt");
assertThat(actualFiles).containsAtLeastElementsIn(expectedFiles);
}
use of com.android.tools.build.bundletool.model.ModuleEntry in project bundletool by google.
the class SuffixStripperTest method removeAssetsTargeting_tcf.
@Test
public void removeAssetsTargeting_tcf() {
ModuleSplit split = ModuleSplit.builder().setModuleName(BundleModuleName.create("base")).setApkTargeting(ApkTargeting.getDefaultInstance()).setVariantTargeting(VariantTargeting.getDefaultInstance()).setAndroidManifest(AndroidManifest.create(androidManifest("com.test.app"))).setMasterSplit(true).setEntries(ImmutableList.of(createModuleEntryForFile("assets/untargeted_texture.dat", DUMMY_CONTENT), createModuleEntryForFile("assets/textures#tcf_etc1/texture.dat", DUMMY_CONTENT), createModuleEntryForFile("assets/textures#tcf_etc1/other_texture.dat", DUMMY_CONTENT))).setAssetsConfig(assets(targetedAssetsDirectory("assets/textures#tcf_etc1", assetsDirectoryTargeting(textureCompressionTargeting(ETC1_RGB8))))).build();
ModuleSplit strippedSplit = SuffixStripper.createForDimension(SplitDimension.Value.TEXTURE_COMPRESSION_FORMAT).removeAssetsTargeting(split);
// Check that the ATC and untargeted sibling folders have been excluded, and suffix has been
// stripped.
assertThat(strippedSplit.getEntries()).hasSize(3);
assertThat(strippedSplit.getEntries().stream().map(ModuleEntry::getPath)).containsExactly(ZipPath.create("assets/untargeted_texture.dat"), ZipPath.create("assets/textures/texture.dat"), ZipPath.create("assets/textures/other_texture.dat"));
assertThat(strippedSplit.getAssetsConfig().get().getDirectoryCount()).isEqualTo(1);
assertThat(strippedSplit.getAssetsConfig().get().getDirectory(0).getPath()).isEqualTo("assets/textures");
// Check that the APK and Variant targeting were applied.
assertThat(strippedSplit.getApkTargeting()).isEqualToDefaultInstance();
assertThat(strippedSplit.getVariantTargeting()).isEqualToDefaultInstance();
}
use of com.android.tools.build.bundletool.model.ModuleEntry in project bundletool by google.
the class SystemApksGeneratorTest method uncompressedDexFiles_enabled.
@Test
public void uncompressedDexFiles_enabled() throws Exception {
BundleModule baseModule = new BundleModuleBuilder("base").addFile("dex/classes.dex").setManifest(androidManifestForFeature("com.test.app")).build();
ApkOptimizations apkOptimizations = splitOptimizations().toBuilder().setUncompressDexFiles(true).build();
ImmutableList<ModuleSplit> shards = systemApksGenerator.generateSystemApks(/* modules= */
ImmutableList.of(baseModule), /* modulesToFuse= */
ImmutableSet.of(BASE_MODULE_NAME), apkOptimizations);
assertThat(shards).hasSize(1);
ModuleSplit fatApk = shards.get(0);
assertThat(fatApk.findEntry("dex/classes.dex").map(ModuleEntry::getForceUncompressed)).hasValue(true);
}
use of com.android.tools.build.bundletool.model.ModuleEntry in project bundletool by google.
the class LocaleConfigXmlInjector method injectLocaleConfigXml.
private static ModuleSplit injectLocaleConfigXml(ModuleSplit split, XmlNode xmlNode) {
ResourceInjector resourceInjector = ResourceInjector.fromModuleSplit(split);
ResourceId resourceId = resourceInjector.addResource(XML_TYPE_NAME, createXmlEntry());
ModuleEntry localesConfigEntry = addLocalesConfigEntry(xmlNode);
return split.toBuilder().setResourceTable(resourceInjector.build()).setEntries(ImmutableList.<ModuleEntry>builder().addAll(split.getEntries()).add(localesConfigEntry).build()).setAndroidManifest(split.getAndroidManifest().toEditor().setLocaleConfig(resourceId.getFullResourceId()).save()).build();
}
use of com.android.tools.build.bundletool.model.ModuleEntry in project bundletool by google.
the class SplitsXmlInjector method injectSplitsXml.
private static ModuleSplit injectSplitsXml(ModuleSplit split, XmlNode xmlNode) {
ZipPath resourcePath = getUniqueResourcePath(split);
ResourceInjector resourceInjector = ResourceInjector.fromModuleSplit(split);
ResourceId resourceId = resourceInjector.addResource(XML_TYPE_NAME, createXmlEntry(resourcePath));
return split.toBuilder().setResourceTable(resourceInjector.build()).setEntries(ImmutableList.<ModuleEntry>builder().addAll(split.getEntries()).add(ModuleEntry.builder().setPath(resourcePath).setContent(ByteSource.wrap(xmlNode.toByteArray())).build()).build()).setAndroidManifest(split.getAndroidManifest().toEditor().addMetaDataResourceId(METADATA_KEY, resourceId.getFullResourceId()).save()).build();
}
Aggregations