Search in sources :

Example 1 with ModuleDeliveryType

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();
        }
    }
}
Also used : ModuleDeliveryType(com.android.tools.build.bundletool.model.ModuleDeliveryType)

Example 2 with ModuleDeliveryType

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();
    }
}
Also used : ModuleDeliveryType(com.android.tools.build.bundletool.model.ModuleDeliveryType)

Example 3 with ModuleDeliveryType

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);
}
Also used : ModuleType(com.android.tools.build.bundletool.model.BundleModule.ModuleType) ModuleDeliveryType(com.android.tools.build.bundletool.model.ModuleDeliveryType)

Aggregations

ModuleDeliveryType (com.android.tools.build.bundletool.model.ModuleDeliveryType)3 ModuleType (com.android.tools.build.bundletool.model.BundleModule.ModuleType)1