In Android development, we use gradle building system. We often see some usual codes in build.gradle:
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
testOptions {
unitTests.returnDefaultValues = true
}
defaultConfig {
applicationId "xxx"
minSdkVersion 19
targetSdkVersion 28
We also see some unusual codes like:
javaCompileOptions {
annotationProcessorOptions {
arguments = ["xxx": "xxx"]
}
}
applicationVariants.all { variant ->
buildType = variant.buildType.name // Sets the current build type
}
How do you know there's a buildType
variable of variant
? What's the object of variant
? Can I see its details?
We often copy/paste those codes from internet without thinking too much, so we don't have a systematic knowledge of these declarations and variables.
I wonder if there is some documents and/or codes of such things? So that we can search like in a Javadoc, and write gradle files more freely, instead of just copy/paste.
I know there are two site:
http://google.github.io/android-gradle-dsl/current/index.html
But they don't clarify why there's the variant.buildType
definition. You may find in the following class:
there is a definition:
getBuildTypeName()
You may think variant.buildType
is from this.
BUT. getFlavorNames()
returns a list, while variant.flavorName
is a string.
So, the above 2 documents are not enough, I believe.