Search in sources :

Example 1 with ProductFlavor

use of com.android.builder.model.ProductFlavor in project meghanada-server by mopemope.

the class AndroidSupport method getAndroidSources.

private Map<String, Set<File>> getAndroidSources(ProductFlavorContainer defaultConfig) {
    Map<String, Set<File>> sources = new HashMap<>();
    ProductFlavor productFlavor = defaultConfig.getProductFlavor();
    String name = productFlavor.getName();
    SourceProvider sourceProvider = defaultConfig.getSourceProvider();
    AndroidSupport.setAndroidSources(sources, sourceProvider, false);
    // extra
    Collection<SourceProviderContainer> extraSourceProviders = defaultConfig.getExtraSourceProviders();
    extraSourceProviders.forEach(sourceProviderContainer -> {
        String artifactName = sourceProviderContainer.getArtifactName();
        SourceProvider provider = sourceProviderContainer.getSourceProvider();
        boolean isTest = artifactName.contains(TEST_SUFFIX);
        AndroidSupport.setAndroidSources(sources, provider, isTest);
    });
    return sources;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) ProductFlavor(com.android.builder.model.ProductFlavor) SourceProvider(com.android.builder.model.SourceProvider) SourceProviderContainer(com.android.builder.model.SourceProviderContainer)

Example 2 with ProductFlavor

use of com.android.builder.model.ProductFlavor 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

ProductFlavor (com.android.builder.model.ProductFlavor)2 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 SourceProvider (com.android.builder.model.SourceProvider)1 SourceProviderContainer (com.android.builder.model.SourceProviderContainer)1 File (java.io.File)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1