RealAndroidSourceSetsParser

class RealAndroidSourceSetsParser(val parsedConfigurations: Configurations, val extension: BaseExtension, val hasTestFixturesPlugin: Boolean, val gradleProject: GradleProject, val kotlinEnvironmentFactory: KotlinEnvironmentFactory) : AndroidSourceSetsParser(source)

Given this Android config block:

android {
buildTypes {
register("internalRelease").configure {
isMinifyEnabled = true
isShrinkResources = true
matchingFallbacks.add("release")
}
}
flavorDimensions("shade", "color")
productFlavors {
create("light") { dimension = "shade" }
create("dark") { dimension = "shade" }
create("red") { dimension = "color" }
create("blue") { dimension = "color" }
}
}

BuildType names: [debug, internalRelease, release]

Primitive flavor names: [light, dark, red, blue]

Combined flavor names: [lightRed, lightBlue, darkRed, darkBlue]

Flavor dimensions are just arbitrary keys which allow us to group flavors together. These names are not used to create SourceSets. The final collection of SourceSets would be unaffected if these were just named something like ["a", "b"].

Flavor dimensions (these do not become SourceSets): [[shade, color]]
Product flavors: { color: [[blue, red]], shade: [[light, dark]] }

Flavors get combined via matrix multiplication and string concatenation in order to create more SourceSets. The order of the concatenated string components ("light", "red", etc.) is determined by the order in which their corresponding flavor dimensions are added. In this example, since "shade" is added before "color", then the flavors of "shade" ("light", "dark") will be before the flavors of "color" ("red", "blue").

[light, dark] x [red, blue] = [lightRed, lightBlue, darkRed, darkBlue]

Build Variants are now created via more matrix multiplication and string concatenation, between the BuildType and combined flavor names. BuildType names are always last.

[lightRed, lightBlue, darkRed, darkBlue] x [debug, internalRelease, release] =
[
lightRedDebug, lightRedRelease, lightRedInternalRelease,
lightBlueDebug, lightBlueRelease, lightBlueInternalRelease,
darkRedDebug, darkRedRelease, darkRedInternalRelease,
darkBlueDebug, darkBlueRelease, darkBlueInternalRelease
]

Finally, a "main" SourceSet is always created.

So just within the production code sources, we get all these SourceSets:

// primitives
main
light dark
red blue
debug internalRelease release

// flavor combinations
lightRed darkRed lightBlue darkBlue

// flavor combinations with build types
lightRedDebug lightRedInternalRelease lightRedRelease
darkRedDebug darkRedInternalRelease darkRedRelease
lightBlueDebug lightBlueInternalRelease lightBlueRelease
darkBlueDebug darkBlueInternalRelease darkBlueRelease

Since

0.12.0

Constructors

Link copied to clipboard
private constructor(parsedConfigurations: Configurations, extension: BaseExtension, hasTestFixturesPlugin: Boolean, gradleProject: GradleProject, kotlinEnvironmentFactory: KotlinEnvironmentFactory)

Types

Link copied to clipboard
class Factory @Inject constructor(val kotlinEnvironmentFactory: KotlinEnvironmentFactory) : AndroidSourceSetsParser.Factory

Properties

Link copied to clipboard
Link copied to clipboard
private val extension: BaseExtension
Link copied to clipboard
Link copied to clipboard
private val gradleAndroidSourceSets: Map<String, DefaultAndroidSourceSet>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
private fun TestVariant.nameWithoutAndroidTestSuffix(): String

This removes the -AndroidTest suffix from variant names. SourceSet names don't get this suffix

Link copied to clipboard
private fun UnitTestVariant.nameWithoutUnitTestSuffix(): String

This removes the -UnitTest suffix from variant names. SourceSet names don't get this suffix

Link copied to clipboard
open override fun parse(): SourceSets
Link copied to clipboard
Link copied to clipboard
private fun BaseExtension.publishedVariants(): DomainObjectSet<out BaseVariant>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
private fun DefaultAndroidSourceSet.toSourceSetOrNull(): McSourceSet?