Search in sources :

Example 1 with BundleConfig

use of com.android.bundle.Config.BundleConfig in project bundletool by google.

the class BuildApksManager method getCommonSplitApkGenerationConfiguration.

private ApkGenerationConfiguration.Builder getCommonSplitApkGenerationConfiguration(AppBundle appBundle) {
    BundleConfig bundleConfig = appBundle.getBundleConfig();
    Version bundleToolVersion = Version.of(bundleConfig.getBundletool().getVersion());
    ApkGenerationConfiguration.Builder apkGenerationConfiguration = ApkGenerationConfiguration.builder().setOptimizationDimensions(apkOptimizations.getSplitDimensions());
    apkGenerationConfiguration.setEnableUncompressedNativeLibraries(apkOptimizations.getUncompressNativeLibraries());
    apkGenerationConfiguration.setEnableDexCompressionSplitter(apkOptimizations.getUncompressDexFiles());
    apkGenerationConfiguration.setInstallableOnExternalStorage(appBundle.getBaseModule().getAndroidManifest().getInstallLocationValue().map(installLocation -> installLocation.equals("auto") || installLocation.equals("preferExternal")).orElse(false));
    apkGenerationConfiguration.setMasterPinnedResourceIds(appBundle.getMasterPinnedResourceIds());
    apkGenerationConfiguration.setMasterPinnedResourceNames(appBundle.getMasterPinnedResourceNames());
    apkGenerationConfiguration.setSuffixStrippings(apkOptimizations.getSuffixStrippings());
    command.getMinSdkForAdditionalVariantWithV3Rotation().ifPresent(apkGenerationConfiguration::setMinSdkForAdditionalVariantWithV3Rotation);
    return apkGenerationConfiguration;
}
Also used : ApkGenerationConfiguration(com.android.tools.build.bundletool.splitters.ApkGenerationConfiguration) BundleConfig(com.android.bundle.Config.BundleConfig) Version(com.android.tools.build.bundletool.model.version.Version)

Example 2 with BundleConfig

use of com.android.bundle.Config.BundleConfig in project bundletool by google.

the class DumpManager method printBundleConfig.

void printBundleConfig() {
    try (ZipFile zipFile = new ZipFile(bundlePath.toFile())) {
        BundleConfig bundleConfig = extractAndParse(zipFile, ZipPath.create("BundleConfig.pb"), BundleConfig::parseFrom);
        printStream.println(JsonFormat.printer().print(bundleConfig));
    } catch (IOException e) {
        throw new UncheckedIOException("Error occurred when reading the bundle.", e);
    }
}
Also used : BundleConfig(com.android.bundle.Config.BundleConfig) ZipFile(java.util.zip.ZipFile) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException)

Example 3 with BundleConfig

use of com.android.bundle.Config.BundleConfig in project bundletool by google.

the class BundleConfigValidator method validateBundle.

@Override
public void validateBundle(AppBundle bundle) {
    BundleConfig bundleConfig = bundle.getBundleConfig();
    validateVersion(bundleConfig);
    validateCompression(bundleConfig.getCompression());
    validateOptimizations(bundleConfig.getOptimizations());
    validateMasterResources(bundleConfig, bundle);
}
Also used : BundleConfig(com.android.bundle.Config.BundleConfig)

Example 4 with BundleConfig

use of com.android.bundle.Config.BundleConfig in project bundletool by google.

the class BundleModulesValidator method validate.

public ImmutableList<BundleModule> validate(ImmutableList<ZipFile> moduleZips, BundleConfig bundleConfig) {
    for (ZipFile moduleZip : moduleZips) {
        new ValidatorRunner(MODULE_FILE_SUB_VALIDATORS).validateModuleZipFile(moduleZip);
    }
    ImmutableList<BundleModule> modules = moduleZips.stream().map(module -> toBundleModule(module, bundleConfig)).collect(toImmutableList());
    new ValidatorRunner(MODULES_SUB_VALIDATORS).validateBundleModules(modules);
    return modules;
}
Also used : BundleModuleName(com.android.tools.build.bundletool.model.BundleModuleName) ZipPath(com.android.tools.build.bundletool.model.ZipPath) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Predicates.not(com.google.common.base.Predicates.not) ImmutableList(com.google.common.collect.ImmutableList) BundleConfig(com.android.bundle.Config.BundleConfig) ModuleEntry(com.android.tools.build.bundletool.model.ModuleEntry) ZipFile(java.util.zip.ZipFile) VisibleForTesting(com.google.common.annotations.VisibleForTesting) AppBundle(com.android.tools.build.bundletool.model.AppBundle) BundleModule(com.android.tools.build.bundletool.model.BundleModule) ZipUtils(com.android.tools.build.bundletool.model.utils.ZipUtils) ZipEntry(java.util.zip.ZipEntry) ZipFile(java.util.zip.ZipFile) BundleModule(com.android.tools.build.bundletool.model.BundleModule)

Example 5 with BundleConfig

use of com.android.bundle.Config.BundleConfig in project bundletool by google.

the class BundleModulesValidator method toBundleModule.

private BundleModule toBundleModule(ZipFile moduleZipFile, BundleConfig bundleConfig) {
    BundleModule bundleModule = BundleModule.builder().setName(BundleModuleName.create("TEMPORARY_MODULE_NAME")).setBundleConfig(bundleConfig).addEntries(moduleZipFile.stream().filter(not(ZipEntry::isDirectory)).map(zipEntry -> ModuleEntry.builder().setPath(ZipPath.create(zipEntry.getName())).setContent(ZipUtils.asByteSource(moduleZipFile, zipEntry)).build()).collect(toImmutableList())).build();
    BundleModuleName actualModuleName = bundleModule.getAndroidManifest().getSplitId().map(BundleModuleName::create).orElse(BundleModuleName.BASE_MODULE_NAME);
    return bundleModule.toBuilder().setName(actualModuleName).build();
}
Also used : BundleModuleName(com.android.tools.build.bundletool.model.BundleModuleName) ZipPath(com.android.tools.build.bundletool.model.ZipPath) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Predicates.not(com.google.common.base.Predicates.not) ImmutableList(com.google.common.collect.ImmutableList) BundleConfig(com.android.bundle.Config.BundleConfig) ModuleEntry(com.android.tools.build.bundletool.model.ModuleEntry) ZipFile(java.util.zip.ZipFile) VisibleForTesting(com.google.common.annotations.VisibleForTesting) AppBundle(com.android.tools.build.bundletool.model.AppBundle) BundleModule(com.android.tools.build.bundletool.model.BundleModule) ZipUtils(com.android.tools.build.bundletool.model.utils.ZipUtils) ZipEntry(java.util.zip.ZipEntry) BundleModuleName(com.android.tools.build.bundletool.model.BundleModuleName) BundleModule(com.android.tools.build.bundletool.model.BundleModule)

Aggregations

BundleConfig (com.android.bundle.Config.BundleConfig)11 AppBundle (com.android.tools.build.bundletool.model.AppBundle)5 ZipPath (com.android.tools.build.bundletool.model.ZipPath)5 ImmutableList (com.google.common.collect.ImmutableList)5 IOException (java.io.IOException)5 UncheckedIOException (java.io.UncheckedIOException)5 BundleModule (com.android.tools.build.bundletool.model.BundleModule)4 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)4 ZipFile (java.util.zip.ZipFile)4 ModuleEntry (com.android.tools.build.bundletool.model.ModuleEntry)3 Path (java.nio.file.Path)3 BundleModuleName (com.android.tools.build.bundletool.model.BundleModuleName)2 ZipUtils (com.android.tools.build.bundletool.model.utils.ZipUtils)2 Version (com.android.tools.build.bundletool.model.version.Version)2 Entry (com.android.zipflinger.Entry)2 ZipArchive (com.android.zipflinger.ZipArchive)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 Predicates.not (com.google.common.base.Predicates.not)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 ZipEntry (java.util.zip.ZipEntry)2