com.android.builder.model.ProductFlavor Java Examples
The following examples show how to use
com.android.builder.model.ProductFlavor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Project.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * Adds in the resConfig values specified by the given flavor container, assuming * it's in one of the relevant variantFlavors, into the given set */ private static void addResConfigsFromFlavor(@NonNull Set<String> relevantDensities, @Nullable List<String> variantFlavors, @NonNull ProductFlavorContainer container) { ProductFlavor flavor = container.getProductFlavor(); if (variantFlavors == null || variantFlavors.contains(flavor.getName())) { if (!flavor.getResourceConfigurations().isEmpty()) { for (String densityName : flavor.getResourceConfigurations()) { Density density = Density.getEnum(densityName); if (density != null && density.isRecommended() && density != Density.NODPI && density != Density.ANYDPI) { relevantDensities.add(densityName); } } } } }
Example #2
Source File: AndroidSupport.java From meghanada-server with GNU General Public License v3.0 | 6 votes |
private static Map<String, Set<File>> getAndroidSources(ProductFlavorContainer defaultConfig) { Map<String, Set<File>> sources = new HashMap<>(8); 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; }
Example #3
Source File: VariantConfiguration.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * Returns a base name that includes the given splits name. * * @param splitName the split name * @return a unique name made up of the variant and split names. */ @NonNull public String computeBaseNameWithSplits(@NonNull String splitName) { StringBuilder sb = new StringBuilder(); if (!mFlavors.isEmpty()) { for (ProductFlavor pf : mFlavors) { sb.append(pf.getName()).append('-'); } } sb.append(splitName).append('-'); sb.append(mBuildType.getName()); return sb.toString(); }
Example #4
Source File: VariantConfiguration.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * Returns the full, unique name of the variant, including BuildType, flavors and test, * dash separated. (similar to full name but with dashes) * * @return the name of the variant */ @NonNull public String getBaseName() { if (mBaseName == null) { StringBuilder sb = new StringBuilder(); if (!mFlavors.isEmpty()) { for (ProductFlavor pf : mFlavors) { sb.append(pf.getName()).append('-'); } } sb.append(mBuildType.getName()); mBaseName = sb.toString(); } return mBaseName; }
Example #5
Source File: TranslationDetector.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * Adds in the resConfig values specified by the given flavor container, assuming * it's in one of the relevant variantFlavors, into the given set */ private static void addResConfigsFromFlavor(@NonNull Set<String> relevantLanguages, @Nullable List<String> variantFlavors, @NonNull ProductFlavorContainer container) { ProductFlavor flavor = container.getProductFlavor(); if (variantFlavors == null || variantFlavors.contains(flavor.getName())) { if (!flavor.getResourceConfigurations().isEmpty()) { for (String resConfig : flavor.getResourceConfigurations()) { // Look for languages; these are of length 2. (ResConfigs // can also refer to densities, etc.) if (resConfig.length() == 2) { relevantLanguages.add(resConfig); } } } } }
Example #6
Source File: IconDetector.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * Adds in the resConfig values specified by the given flavor container, assuming * it's in one of the relevant variantFlavors, into the given set */ private static void addResConfigsFromFlavor(@NonNull Set<String> relevantDensities, @Nullable List<String> variantFlavors, @NonNull ProductFlavorContainer container) { ProductFlavor flavor = container.getProductFlavor(); if (variantFlavors == null || variantFlavors.contains(flavor.getName())) { if (!flavor.getResourceConfigurations().isEmpty()) { for (String densityName : flavor.getResourceConfigurations()) { Density density = Density.getEnum(densityName); if (density != null && density.isRecommended() && density != Density.NODPI && density != Density.ANYDPI) { relevantDensities.add(densityName); } } } } }
Example #7
Source File: VariantManager.java From javaide with GNU General Public License v3.0 | 6 votes |
private static void createCompoundSourceSets( @NonNull List<? extends ProductFlavor> productFlavorList, GradleVariantConfiguration variantConfig, NamedDomainObjectContainer<AndroidSourceSet> sourceSetsContainer) { if (!productFlavorList.isEmpty() && !variantConfig.getType().isSingleBuildType()) { DefaultAndroidSourceSet variantSourceSet = (DefaultAndroidSourceSet) sourceSetsContainer.maybeCreate( computeSourceSetName( variantConfig.getFullName(), variantConfig.getType())); variantConfig.setVariantSourceProvider(variantSourceSet); } if (productFlavorList.size() > 1) { DefaultAndroidSourceSet multiFlavorSourceSet = (DefaultAndroidSourceSet) sourceSetsContainer.maybeCreate( computeSourceSetName( variantConfig.getFlavorName(), variantConfig.getType())); variantConfig.setMultiFlavorSourceProvider(multiFlavorSourceSet); } }
Example #8
Source File: ImmutableFlavorList.java From javaide with GNU General Public License v3.0 | 6 votes |
@NonNull @Override public Iterator<ProductFlavor> iterator() { final Iterator<? extends ProductFlavor> baseIterator = list.iterator(); return new Iterator<ProductFlavor>() { @Override public boolean hasNext() { return baseIterator.hasNext(); } @Override public ProductFlavor next() { return immutableObjectProvider.getProductFlavor(baseIterator.next()); } @Override public void remove() { throw new UnsupportedOperationException(); } }; }
Example #9
Source File: LintGradleProject.java From javaide with GNU General Public License v3.0 | 6 votes |
@Override @NonNull public AndroidVersion getTargetSdkVersion() { if (mTargetSdkVersion == null) { ApiVersion targetSdk = mVariant.getMergedFlavor().getTargetSdkVersion(); if (targetSdk == null) { ProductFlavor flavor = mProject.getDefaultConfig().getProductFlavor(); targetSdk = flavor.getTargetSdkVersion(); } if (targetSdk != null) { mTargetSdkVersion = LintUtils.convertVersion(targetSdk, mClient.getTargets()); } else { mTargetSdkVersion = super.getTargetSdkVersion(); // from manifest } } return mTargetSdkVersion; }
Example #10
Source File: LintGradleProject.java From javaide with GNU General Public License v3.0 | 6 votes |
@Override @NonNull public AndroidVersion getMinSdkVersion() { if (mMinSdkVersion == null) { ApiVersion minSdk = mVariant.getMergedFlavor().getMinSdkVersion(); if (minSdk == null) { ProductFlavor flavor = mProject.getDefaultConfig().getProductFlavor(); minSdk = flavor.getMinSdkVersion(); } if (minSdk != null) { mMinSdkVersion = LintUtils.convertVersion(minSdk, mClient.getTargets()); } else { mMinSdkVersion = super.getMinSdkVersion(); // from manifest } } return mMinSdkVersion; }
Example #11
Source File: ProcessManifest.java From javaide with GNU General Public License v3.0 | 6 votes |
@Override public void execute(@NonNull ProcessManifest processManifest) { final VariantConfiguration config = scope.getVariantConfiguration(); final AndroidBuilder androidBuilder = scope.getGlobalScope().getAndroidBuilder(); // get single output for now. final BaseVariantOutputData variantOutputData = scope.getVariantData().getOutputs().get(0); variantOutputData.manifestProcessorTask = processManifest; processManifest.setAndroidBuilder(androidBuilder); processManifest.setVariantName(config.getFullName()); processManifest.setVariantConfiguration(config); final ProductFlavor mergedFlavor = config.getMergedFlavor(); processManifest.setMinSdkVersion(getMinSdkVersion(androidBuilder, mergedFlavor, processManifest)); processManifest.setTargetSdkVersion(getTargetSdkVersion(androidBuilder, mergedFlavor, processManifest)); processManifest.setMaxSdkVersion(getMaxSdkVersion(androidBuilder, mergedFlavor)); processManifest.setManifestOutputFile(variantOutputData.getScope().getManifestOutputFile()); processManifest.setAaptFriendlyManifestOutputFile( new File(scope.getGlobalScope().getIntermediatesDir(), TaskManager.DIR_BUNDLES + "/" + config.getDirName() + "/aapt/AndroidManifest.xml")); }
Example #12
Source File: PreProcessManifestAction.java From atlas with Apache License 2.0 | 5 votes |
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()); } } } }
Example #13
Source File: ProductFlavorCombo.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Remove all null reference from an array and create an ImmutableList it. */ private static ImmutableList<ProductFlavor> filterNullFromArray(ProductFlavor[] flavors) { ImmutableList.Builder<ProductFlavor> builder = ImmutableList.builder(); for (ProductFlavor flavor : flavors) { if (flavor != null) { builder.add(flavor); } } return builder.build(); }
Example #14
Source File: ModelBuilder.java From javaide with GNU General Public License v3.0 | 5 votes |
@NonNull private static List<String> getProductFlavorNames( @NonNull BaseVariantData<? extends BaseVariantOutputData> variantData) { List<CoreProductFlavor> productFlavors = variantData.getVariantConfiguration() .getProductFlavors(); List<String> flavorNames = Lists.newArrayListWithCapacity(productFlavors.size()); for (ProductFlavor flavor : productFlavors) { flavorNames.add(flavor.getName()); } return flavorNames; }
Example #15
Source File: VariantManager.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Create all variants. */ public void populateVariantDataList() { if (productFlavors.isEmpty()) { createVariantDataForProductFlavors(Collections.<ProductFlavor>emptyList()); } else { List<String> flavorDimensionList = extension.getFlavorDimensionList(); // Create iterable to get GradleProductFlavor from ProductFlavorData. Iterable<CoreProductFlavor> flavorDsl = Iterables.transform( productFlavors.values(), new Function<ProductFlavorData<CoreProductFlavor>, CoreProductFlavor>() { @Override public CoreProductFlavor apply( ProductFlavorData<CoreProductFlavor> data) { return data.getProductFlavor(); } }); // Get a list of all combinations of product flavors. List<ProductFlavorCombo<CoreProductFlavor>> flavorComboList = ProductFlavorCombo.createCombinations( flavorDimensionList, flavorDsl); for (ProductFlavorCombo<CoreProductFlavor> flavorCombo : flavorComboList) { //noinspection unchecked createVariantDataForProductFlavors( (List<ProductFlavor>) (List) flavorCombo.getFlavorList()); } } }
Example #16
Source File: ProductFlavorImpl.java From javaide with GNU General Public License v3.0 | 5 votes |
@NonNull static ProductFlavorImpl cloneFlavor( @NonNull ProductFlavor productFlavor, @Nullable ApiVersion minSdkVersionOverride, @Nullable ApiVersion targetSdkVersionOverride) { ProductFlavorImpl clonedFlavor = new ProductFlavorImpl(productFlavor); clonedFlavor.name = productFlavor.getName(); clonedFlavor.mDimension = productFlavor.getDimension(); clonedFlavor.mMinSdkVersion = minSdkVersionOverride != null ? minSdkVersionOverride : ApiVersionImpl.clone(productFlavor.getMinSdkVersion()); clonedFlavor.mTargetSdkVersion = targetSdkVersionOverride != null ? targetSdkVersionOverride : ApiVersionImpl.clone(productFlavor.getTargetSdkVersion()); clonedFlavor.mMaxSdkVersion = targetSdkVersionOverride != null ? null /* we remove the maxSdkVersion when dealing with a preview release */ : productFlavor.getMaxSdkVersion(); clonedFlavor.mVersionCode = productFlavor.getVersionCode(); clonedFlavor.mVersionName = productFlavor.getVersionName(); clonedFlavor.mApplicationId = productFlavor.getApplicationId(); clonedFlavor.mResourceConfigurations = ImmutableSet.copyOf( productFlavor.getResourceConfigurations()); return clonedFlavor; }
Example #17
Source File: ReadOnlyObjectProvider.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Retuens an read-only version of a groupable product flavor. * * @param productFlavor the product flavor. * @return an read-only version. */ @NonNull public ProductFlavor getProductFlavor(@NonNull ProductFlavor productFlavor) { ProductFlavor readOnlyProductFlavor = readOnlyFlavors.get(productFlavor); if (readOnlyProductFlavor == null) { readOnlyFlavors.put(productFlavor, readOnlyProductFlavor = new ReadOnlyProductFlavor( productFlavor, this)); } return readOnlyProductFlavor; }
Example #18
Source File: ReadOnlyObjectProvider.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Returns an read-only version of the default config. * * @param defaultConfig the default config. * @return an read-only version. */ @NonNull ProductFlavor getDefaultConfig(@NonNull ProductFlavor defaultConfig) { if (readOnlyDefaultConfig != null) { if (readOnlyDefaultConfig.productFlavor != defaultConfig) { throw new IllegalStateException("Different DefaultConfigs passed to ApiObjectProvider"); } } else { readOnlyDefaultConfig = new ReadOnlyProductFlavor(defaultConfig, this); } return readOnlyDefaultConfig; }
Example #19
Source File: ProcessManifest.java From javaide with GNU General Public License v3.0 | 5 votes |
private String getMinSdkVersion(AndroidBuilder androidBuilder, ProductFlavor mergedFlavor, ProcessManifest processManifest) { if (androidBuilder.isPreviewTarget()) { return androidBuilder.getTargetCodename(); } final ApiVersion version = mergedFlavor.getMinSdkVersion(); return (version == null ? null : version.getApiString()); }
Example #20
Source File: ProcessManifest.java From javaide with GNU General Public License v3.0 | 5 votes |
private String getTargetSdkVersion(AndroidBuilder androidBuilder, ProductFlavor mergedFlavor, ProcessManifest processManifest) { if (androidBuilder.isPreviewTarget()) { return androidBuilder.getTargetCodename(); } final ApiVersion version = mergedFlavor.getTargetSdkVersion(); return (version == null ? null : version.getApiString()); }
Example #21
Source File: ProcessManifest.java From javaide with GNU General Public License v3.0 | 5 votes |
private Integer getMaxSdkVersion(AndroidBuilder androidBuilder, ProductFlavor mergedFlavor) { if (androidBuilder.isPreviewTarget()) { return null; } return mergedFlavor.getMaxSdkVersion(); }
Example #22
Source File: BaseVariantImpl.java From javaide with GNU General Public License v3.0 | 5 votes |
@Override @NonNull public List<ProductFlavor> getProductFlavors() { return new ImmutableFlavorList( getVariantData().getVariantConfiguration().getProductFlavors(), readOnlyObjectProvider); }
Example #23
Source File: VariantFilter.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Returns the list of read-only flavors, or an empty list. * <p> * <p>See {@link com.android.build.gradle.internal.dsl.ProductFlavor} for properties * present on the returned objects. */ @NonNull @Override public List<ProductFlavor> getFlavors() { return flavors != null ? new ImmutableFlavorList(flavors, readOnlyObjectProvider) : Collections.<ProductFlavor>emptyList(); }
Example #24
Source File: DefaultProductFlavor.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Clone a given product flavor. * * @param productFlavor the flavor to clone. * * @return a new instance that is a clone of the flavor. */ @NonNull static ProductFlavor clone(@NonNull ProductFlavor productFlavor) { DefaultProductFlavor flavor = new DefaultProductFlavor(productFlavor.getName()); flavor._initWith(productFlavor); flavor.mDimension = productFlavor.getDimension(); flavor.mMinSdkVersion = productFlavor.getMinSdkVersion(); flavor.mTargetSdkVersion = productFlavor.getTargetSdkVersion(); flavor.mMaxSdkVersion = productFlavor.getMaxSdkVersion(); flavor.mVersionCode = productFlavor.getVersionCode(); flavor.mVersionName = productFlavor.getVersionName(); flavor.mApplicationId = productFlavor.getApplicationId(); flavor.mSigningConfig = productFlavor.getSigningConfig(); flavor.addResourceConfigurations(productFlavor.getResourceConfigurations()); flavor.addManifestPlaceholders(productFlavor.getManifestPlaceholders()); flavor.addResValues(productFlavor.getResValues()); flavor.addBuildConfigFields(productFlavor.getBuildConfigFields()); flavor.setMultiDexEnabled(productFlavor.getMultiDexEnabled()); flavor.setMultiDexKeepFile(productFlavor.getMultiDexKeepFile()); flavor.setMultiDexKeepProguard(productFlavor.getMultiDexKeepProguard()); flavor.setJarJarRuleFiles(ImmutableList.copyOf(productFlavor.getJarJarRuleFiles())); return flavor; }
Example #25
Source File: VariantFilter.java From javaide with GNU General Public License v3.0 | 5 votes |
public void reset( @NonNull ProductFlavor defaultConfig, @NonNull BuildType buildType, @Nullable List<ProductFlavor> flavors) { ignore = false; this.defaultConfig = defaultConfig; this.buildType = buildType; this.flavors = flavors; }
Example #26
Source File: ReadOnlyProductFlavor.java From javaide with GNU General Public License v3.0 | 5 votes |
ReadOnlyProductFlavor( @NonNull ProductFlavor productFlavor, @NonNull ReadOnlyObjectProvider readOnlyObjectProvider) { super(productFlavor); this.productFlavor = productFlavor; this.readOnlyObjectProvider = readOnlyObjectProvider; }
Example #27
Source File: DefaultProductFlavor.java From javaide with GNU General Public License v3.0 | 4 votes |
/** * Sets the minSdkVersion to the given value. */ @NonNull public ProductFlavor setMinSdkVersion(ApiVersion minSdkVersion) { mMinSdkVersion = minSdkVersion; return this; }
Example #28
Source File: DefaultProductFlavor.java From javaide with GNU General Public License v3.0 | 4 votes |
/** * Sets the application id. */ @NonNull public ProductFlavor setApplicationId(String applicationId) { mApplicationId = applicationId; return this; }
Example #29
Source File: VariantConfiguration.java From javaide with GNU General Public License v3.0 | 4 votes |
@NonNull public ProductFlavor getMergedFlavor() { return mMergedFlavor; }
Example #30
Source File: DefaultProductFlavor.java From javaide with GNU General Public License v3.0 | 4 votes |
/** Sets the targetSdkVersion to the given value. */ @NonNull public ProductFlavor setTargetSdkVersion(@Nullable ApiVersion targetSdkVersion) { mTargetSdkVersion = targetSdkVersion; return this; }