use of com.android.tools.build.bundletool.model.ModuleDeliveryType in project bundletool by google.
the class ModuleDependencyValidator method checkValidModuleDeliveryTypeDependencies.
/**
* Checks that an install-time module does not depend on an on-demand module.
*/
private static void checkValidModuleDeliveryTypeDependencies(Multimap<String, String> moduleDependenciesMap, ImmutableMap<String, BundleModule> modulesByName) {
for (Entry<String, String> dependencyEntry : moduleDependenciesMap.entries()) {
String moduleName = dependencyEntry.getKey();
String moduleDep = dependencyEntry.getValue();
ModuleDeliveryType moduleDeliveryType = modulesByName.get(moduleName).getDeliveryType();
ModuleDeliveryType depDeliveryType = modulesByName.get(moduleDep).getDeliveryType();
// Conditional modules can only depend on always installed modules.
if (moduleDeliveryType.equals(ModuleDeliveryType.CONDITIONAL_INITIAL_INSTALL) && !depDeliveryType.equals(ModuleDeliveryType.ALWAYS_INITIAL_INSTALL)) {
throw InvalidBundleException.builder().withUserMessage("Conditional module '%s' cannot depend on a module '%s' that is not install-time.", moduleName, moduleDep).build();
}
if (moduleDeliveryType.equals(ModuleDeliveryType.NO_INITIAL_INSTALL) && depDeliveryType.equals(ModuleDeliveryType.CONDITIONAL_INITIAL_INSTALL)) {
throw InvalidBundleException.builder().withUserMessage("An on-demand module '%s' cannot depend on a conditional module '%s'.", moduleName, moduleDep).build();
}
if (moduleDeliveryType.equals(ModuleDeliveryType.ALWAYS_INITIAL_INSTALL) && !depDeliveryType.equals(ModuleDeliveryType.ALWAYS_INITIAL_INSTALL)) {
throw InvalidBundleException.builder().withUserMessage("Install-time module '%s' cannot depend on a module '%s' that is not " + "install-time.", moduleName, moduleDep).build();
}
}
}
use of com.android.tools.build.bundletool.model.ModuleDeliveryType in project bundletool by google.
the class AndroidManifestValidator method validateDeliverySettings.
private static void validateDeliverySettings(BundleModule module) {
boolean deliveryTypeDeclared = module.getAndroidManifest().isDeliveryTypeDeclared();
ModuleDeliveryType deliveryType = module.getDeliveryType();
if (module.getAndroidManifest().getOnDemandAttribute().isPresent() && module.getAndroidManifest().getManifestDeliveryElement().isPresent()) {
throw InvalidBundleException.builder().withUserMessage("Module '%s' cannot use <dist:delivery> settings and legacy dist:onDemand " + "attribute at the same time", module.getName()).build();
}
if (module.isBaseModule()) {
// In the base module, onDemand must be either not set or false
if (deliveryType.equals(ModuleDeliveryType.NO_INITIAL_INSTALL)) {
throw InvalidBundleException.builder().withUserMessage("The base module cannot be marked on-demand since it will always be served.").build();
}
if (deliveryType.equals(ModuleDeliveryType.CONDITIONAL_INITIAL_INSTALL)) {
throw InvalidBundleException.builder().withUserMessage("The base module cannot have conditions since it will always be served.").build();
}
} else if (!deliveryTypeDeclared) {
throw InvalidBundleException.builder().withUserMessage("The module must explicitly set its delivery options using the " + "<dist:delivery> element (module: '%s').", module.getName()).build();
}
}
use of com.android.tools.build.bundletool.model.ModuleDeliveryType in project bundletool by google.
the class ModuleCompressionManager method shouldForceUncompressAssets.
/**
* Returns whether all assets should be uncompressed in that module.
*/
boolean shouldForceUncompressAssets(BundleConfig bundleConfig, AndroidManifest moduleManifest) {
boolean shouldForceInstallTimeAssetModulesUncompressed = !bundleConfig.getCompression().getInstallTimeAssetModuleDefaultCompression().equals(AssetModuleCompression.COMPRESSED);
ModuleDeliveryType moduleDeliveryType = moduleManifest.getModuleDeliveryType();
ModuleType moduleType = moduleManifest.getModuleType();
boolean isInstallTimeModule = moduleDeliveryType.equals(ALWAYS_INITIAL_INSTALL) || moduleDeliveryType.equals(CONDITIONAL_INITIAL_INSTALL);
return moduleType.equals(ModuleType.ASSET_MODULE) && (shouldForceInstallTimeAssetModulesUncompressed || !isInstallTimeModule);
}
Aggregations