Search in sources :

Example 1 with DefaultProductFlavor

use of com.android.builder.core.DefaultProductFlavor in project atlas by alibaba.

the class PreProcessManifestAction method modifyForIncremental.

private void modifyForIncremental(MergeManifests mergeManifests, List<ManifestProvider> allManifest) {
    if (appVariantContext.getAtlasExtension().getTBuildConfig().isIncremental()) {
        File mainManifest = mergeManifests.getMainManifest();
        File baseManifest = appVariantContext.apContext.getBaseModifyManifest();
        // allManifest.add(new ManifestHelper.MainManifestProvider(mainManifest, "main-manifest"));
        ConventionMappingHelper.map(mergeManifests, "mainManifest", new Callable<File>() {

            @Override
            public File call() throws Exception {
                return baseManifest;
            }
        });
        if (baseVariantOutput instanceof ApkVariantOutput) {
            // TODO Improve performance
            ApkVariantOutput variantOutputData = (ApkVariantOutput) baseVariantOutput;
            DefaultManifestParser manifestParser = new DefaultManifestParser(baseManifest);
            String versionNameOverride = variantOutputData.getVersionNameOverride();
            if (Strings.isNullOrEmpty(versionNameOverride)) {
                variantOutputData.setVersionNameOverride(manifestParser.getVersionName());
                GradleVariantConfiguration variantConfiguration = appVariantContext.getScope().getVariantConfiguration();
                ProductFlavor mergedFlavor = variantConfiguration.getMergedFlavor();
                String versionName = mergedFlavor.getVersionName();
                if (versionName == null) {
                    ((DefaultProductFlavor) mergedFlavor).setVersionName(manifestParser.getVersionName());
                }
            }
            int versionCodeOverride = variantOutputData.getVersionCodeOverride();
            if (versionCodeOverride == -1) {
                variantOutputData.setVersionCodeOverride(manifestParser.getVersionCode());
            }
        }
    }
}
Also used : ApkVariantOutput(com.android.build.gradle.api.ApkVariantOutput) ProductFlavor(com.android.builder.model.ProductFlavor) DefaultProductFlavor(com.android.builder.core.DefaultProductFlavor) DefaultManifestParser(com.android.builder.core.DefaultManifestParser) GradleVariantConfiguration(com.android.build.gradle.internal.core.GradleVariantConfiguration) DefaultProductFlavor(com.android.builder.core.DefaultProductFlavor) File(java.io.File)

Aggregations

ApkVariantOutput (com.android.build.gradle.api.ApkVariantOutput)1 GradleVariantConfiguration (com.android.build.gradle.internal.core.GradleVariantConfiguration)1 DefaultManifestParser (com.android.builder.core.DefaultManifestParser)1 DefaultProductFlavor (com.android.builder.core.DefaultProductFlavor)1 ProductFlavor (com.android.builder.model.ProductFlavor)1 File (java.io.File)1