commit | 86fe65512d1230aafd9cb974b733f6fd09ac15ce | [log] [tgz] |
---|---|---|
author | Xavier Ducrohet <xav@android.com> | Mon Dec 10 14:59:50 2012 -0800 |
committer | Xavier Ducrohet <xav@android.com> | Wed Dec 19 18:58:16 2012 -0800 |
tree | 93af6083035fda4c76400be8e67eea8477cce6aa | |
parent | cca0ebcf9848a905e1c1ed5139af6d3f64866657 [diff] |
Incremental resource merger support. First a ChangeManager (and associated classes) that detects changed files across build runs. This is to be replaced by Gradle once this information is given to the tasks. Then, a rewrite of ResourceMerger and ResourceSet to allow saving a post run state, and reloading it on the next run, to allow for incremental updates of the merged resource folder by only updating the resources that changed, were removed or were added. Finally a change to the BaseTask to support incremental tasks and provide some default support that actual tasks can use or not. The BaseTask will do some first checks to figure out if incremental runs are supported by the class or by the current state, and call one of two methods to do either full run or incremental run. The MergerResourceTask is changed to use this, and its incremental method does a bit more checking and reverts to full run when it cannot do an incremental run. Finally a bunch of tests to ensure this works fine. Change-Id: I3808e2d57aa45882eaf1030e16b092ecd58d9729
A prototype Gradle plugin to build Android applications. This is intended to be used to explore how such a plugin would look and to develop some ideas about how such a plugin would be implemented.
The plugin is functional, if a bit rough, and can generate packaged applications ready to install.
The plugin adds 2 concepts to the Gradle DSL:
release
and debug
. You can add additional build types.If you do not define any flavors for your product, a default flavor called main
is added.
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.
Compile time dependencies are declared in the usual way.
Have a look at the basic/build.gradle
and customized/build.gradle
build files to see the DSL in action.
android.packageName
- defaults to that specified in src/main/AndroidManifest.xml
android.versionCode
- defaults to that specified in src/main/AndroidManifest.xml
android.versionName
- defaults to that specified in src/main/AndroidManifest.xml
android.target
- defaults to android-16
.android.productFlavors.$flavor.packageName
- defaults to ${android.packageName}
android.productFlavors.$flavor.versionCode
- defaults to ${android.versionCode}
android.productFlavors.$flavor.versionName
- defaults to ${android.versionName}
android.buildTypes.$type.zipAlign
- defaults to true
for release
and false
for debug
sourceSets.main.java.srcDirs
- defaults to src/main/java
sourceSets.main.resources.srcDirs
- defaults to src/main/res
sourceSets.$flavor.java.srcDirs
- defaults to src/$flavor/java
sourceSets.$flavor.resources.srcDirs
- defaults to src/$flavor/res
sourceSets.$buildType.java.srcDirs
- defaults to src/$buildType/java
sourceSets.$buildType.resources.srcDirs
- defaults to src/$buildType/res
sourceSets.test.java.srcDirs
- defaults to src/test/java
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:
gradle
directory contains the plugin implementation.testapps/basic
directory contains a simple application that follows the conventionstestapps/customized
directory contains an application with some custom build types, product flavors and other customizations.testapps/multiproject
directory contains an application composed from several Gradle projects.To build the plugin, run ./gradlew uploadArchives
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
.Some other notes:
sourceSets.main.compileClasspath
as the compile classpath for each variant. Could potentially also include sourceSets.$BuildType.compileClasspath
and sourceSets.$ProductFlavor.compileClasspath
as well.