Android 12 Developer Preview is here! Try it out, and give us your feedback!

VariantSelector

@Incubating interface VariantSelector
com.android.build.api.extension.VariantSelector

Selector to reduce the number of variants that are of interests when calling any of the variant API like AndroidComponentsExtension.beforeVariants.

Summary

Public methods

abstract VariantSelector
all()

Creates a VariantSelector of ComponentIdentitythat includes all the variants for the current module.

abstract VariantSelector
withBuildType(buildType: String)

Returns a new selector for ComponentIdentity objects with a given build type.

abstract VariantSelector
withFlavor(flavorToDimension: Pair<String, String>)

Returns a new selector for ComponentIdentity objects with a given (dimension, flavorName).

abstract VariantSelector
withName(pattern: Pattern)

Returns a new selector for ComponentIdentity objects with a given name pattern.

abstract VariantSelector

Returns a new selector for ComponentIdentity objects with a given name.

Public methods

all

abstract fun all(): VariantSelector

Creates a VariantSelector of ComponentIdentitythat includes all the variants for the current module.

Return
a VariantSelector for all variants.

withBuildType

abstract fun withBuildType(buildType: String): VariantSelector

Returns a new selector for ComponentIdentity objects with a given build type.

Parameters
buildType: String Build type to filter ComponentIdentity on.
Return
An instance of VariantSelector to further filter variants.

withFlavor

abstract fun withFlavor(flavorToDimension: Pair<String, String>): VariantSelector

Returns a new selector for ComponentIdentity objects with a given (dimension, flavorName).

Parameters
flavorToDimension: Pair<String, String> Dimension and flavor to filter ComponentIdentity on.
Return
VariantSelector instance to further filter instances of ComponentIdentity

withName

abstract fun withName(pattern: Pattern): VariantSelector

Returns a new selector for ComponentIdentity objects with a given name pattern.

Parameters
pattern: Pattern Pattern to apply on the org.gradle.api.Named.getName to filter ComponentIdentity instances on

withName

abstract fun withName(name: String): VariantSelector

Returns a new selector for ComponentIdentity objects with a given name.

Parameters
name: String String to test against the org.gradle.api.Named.getName for equality.