commit | 11ea0d5e1ecf518abeaa73f6c3ffcc193f053315 | [log] [tgz] |
---|---|---|
author | Xin Li <[email protected]> | Fri Oct 08 07:56:47 2021 +0000 |
committer | Automerger Merge Worker <[email protected]> | Fri Oct 08 07:56:47 2021 +0000 |
tree | 6e4d5d130a2f2e6047a87ed4b5780ce3d64458a7 | |
parent | b56074854c1f0f72a44bcdd0379f391b75dbd9e1 [diff] | |
parent | f24dc4ea4b16c0f63481aa5f5e0d15b7ea99a82d [diff] |
[automerger skipped] Merge "Merge Android 12" am: 417e4997a4 -s ours am: f43e89aa2c -s ours am: f24dc4ea4b -s ours am skip reason: Merged-In I9494082d36af92b66ff4fc7551d3659b9b51d8ea with SHA-1 8f11dea13b is already in history Original change: https://android-review.googlesource.com/c/platform/tools/build/+/1848036 Change-Id: I70e68ea10c4da9c117c6124a949646c222974bb3
The official Gradle plugin to build Android applications.
The plugin adds several concepts to the Gradle DSL, all in the android extension:
release
and debug
. You can add additional build types.If you do not define any flavors for your product, only the values from the default config are used. Flavor settings override the default config.
From this, the plugin will add the appropriate tasks to build each combination of build type and product flavor. The plugin will also define the following source directories:
src/main/java
- Java source to be included in all application variants.src/main/res
- Resources to be included in all application variants.src/$BuildType/java
- Java source to be included in all application variants with the given build type.src/$BuildType/res
- Java source to be included in all application variants with the given build type.src/$ProductFlavor/java
- Resources to be included in all application variants with the given product flavor.src/$ProductFlavor/res
- Resources to be included in all application variants with the given product flavor.src/test/java
- Test source to be included in all test applications.src/test$ProductFlavor/java
- Test source to be include for the test application for the given product flavor.You can configure these locations by configuring the associated source set provided by the android extension.
Compile time dependencies are declared in the usual way.
Have a look at the tests/basic/build.gradle
build file and other projects in tests customized/build.gradle
to see the DSL in action.
android.target
- required.android.defaultConfig.versionCode
- defaults to that specified in src/main/AndroidManifest.xml
android.defaultConfig.versionName
- defaults to that specified in src/main/AndroidManifest.xml
android.productFlavors.$flavor.packageName
- defaults to that specified in src/main/AndroidManifest.xml
android.productFlavors.$flavor.versionCode
- defaults to ${android.defaultConfig.versionCode}
android.productFlavors.$flavor.versionName
- defaults to ${android.defaultConfig.versionName}
android.buildTypes.$type.zipAlign
- defaults to true
for release
and false
for debug
android.sourceSets.main.java.srcDirs
- defaults to src/main/java
android.sourceSets.main.resources.srcDirs
- defaults to src/main/res
android.sourceSets.$flavor.java.srcDirs
- defaults to src/$flavor/java
android.sourceSets.$flavor.resources.srcDirs
- defaults to src/$flavor/res
android.sourceSets.$buildType.java.srcDirs
- defaults to src/$buildType/java
android.sourceSets.$buildType.resources.srcDirs
- defaults to src/$buildType/res
android.sourceSets.test.java.srcDirs
- defaults to src/test/java
android.sourceSets.test$Flavor.java.srcDirs
- defaults to src/test$Flavor/java
dependencies.compile
- compile time dependencies for all applications.The source tree contains the following:
builder
directory contains the builder library.gradle
directory contains the plugin implementation.tests
directory contains various test applications used both as samples and tests by the plugin build system.To build the plugin, run ./gradlew uploadArchives
To build the plugin for release, removing the SNAPSHOT from the version, run ./gradlew --init-script release.gradle <tasks>
To import the plugin into the IDE, run ./gradlew idea
or ./gradlew eclipse
.
To build a test application:
local.properties
file to point at your local install of the Android SDK. Normally, these files would not be checked into source control, but would be generated when the project is bootstrapped.../../gradlew tasks
to see the tasks that are available.You can also run these tasks:
assemble
- builds all combinations of build type and product flavorassemble$BuildType
- build all flavors for the given build type.assemble$ProductFlavor
- build all build types for the given product flavor.assemble$ProductFlavor$BuildType
- build the given application variant.install$ProductFlavor$BuildType
- build and install the given application variant.For each variant (product-flavor, build-type):
build/source
from resource directories (main-source-set, product-flavor-source-set, build-type-source-set)build/libs
build/resources
build/libs
build/libs
.