RealAndroidSourceSetsParser

class RealAndroidSourceSetsParser(    val parsedConfigurations: Configurations,     val extension: BaseExtension,     val hasTestFixturesPlugin: Boolean) : AndroidSourceSetsParser

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

Constructors

Link copied to clipboard
private fun RealAndroidSourceSetsParser(    parsedConfigurations: Configurations,     extension: BaseExtension,     hasTestFixturesPlugin: Boolean)

Types

Link copied to clipboard
class Factory @Inject constructor : AndroidSourceSetsParser.Factory

Functions

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

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

Link copied to clipboard
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
private fun GradleSourceSetName.VariantName.parseNames(testTypeOrNull: GradleSourceSetName.TestType?): ParsedNames
Link copied to clipboard
private fun BaseExtension.publishedVariants(): DomainObjectSet<out BaseVariant>
Link copied to clipboard
private fun MutableMap<String, List<GradleSourceSetName>>.put(key: GradleSourceSetName, values: List<GradleSourceSetName>)
Link copied to clipboard
fun String.removeAndroidTestPrefix(): SourceSetName
Link copied to clipboard
fun String.removeTestFixturesPrefix(): SourceSetName
Link copied to clipboard
fun String.removeTestPrefix(): String
Link copied to clipboard
private fun MutableMap<String, List<GradleSourceSetName>>.saveNameHierarchy(parsedNames: ParsedNames)
Link copied to clipboard
private fun DefaultAndroidSourceSet.toSourceSetOrNull(): SourceSet?
Link copied to clipboard

Properties

Link copied to clipboard
private val buildTypeNames: List<GradleSourceSetName.BuildTypeName>
Link copied to clipboard
private val extension: BaseExtension
Link copied to clipboard
private val flavorDimensions: List<String>
Link copied to clipboard
private val gradleAndroidSourceSets: Map<String, DefaultAndroidSourceSet>
Link copied to clipboard
private val hasTestFixturesPlugin: Boolean
Link copied to clipboard
private val parsedConfigurations: Configurations
Link copied to clipboard
private val productFlavors2D: List<List<GradleSourceSetName.FlavorName>>
Link copied to clipboard
private val sourceSetCache: MutableMap<SourceSetName, SourceSet>
Link copied to clipboard
private val sourceSetNameToUpstreamMap: Map<String, List<GradleSourceSetName>>

Sources

Link copied to clipboard