|author||Xavier Ducrohet <email@example.com>||Fri Sep 21 16:39:16 2012 -0700|
|committer||Xavier Ducrohet <firstname.lastname@example.org>||Fri Sep 21 19:08:20 2012 -0700|
Remove the default java tasks and fix packaging java res Until we use custom source set more adapted to our needs, we delete the default java tasks after each source set is created. This also fixes the packaging of java resources. Right now this reads directly from the source folder, instead of copying to a build folder based on a configurable source set. This should be fixed once we use our own source set. Also fixed packaging java resources from jars and libraries which was missing. This led me to clean up a bit how we handle library deps (especially related to test projects for libraries) and fixed an issue related to merging manifests. Change-Id: I0cc7fb833c2319da501cb92258be7d79b1c3771b
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:
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
customized/build.gradle build files to see the DSL in action.
android.packageName- defaults to that specified in
android.versionCode- defaults to that specified in
android.versionName- defaults to that specified in
android.target- defaults to
android.productFlavors.$flavor.packageName- defaults to
android.productFlavors.$flavor.versionCode- defaults to
android.productFlavors.$flavor.versionName- defaults to
android.buildTypes.$type.zipAlign- defaults to
sourceSets.main.java.srcDirs- defaults to
sourceSets.main.resources.srcDirs- defaults to
sourceSets.$flavor.java.srcDirs- defaults to
sourceSets.$flavor.resources.srcDirs- defaults to
sourceSets.$buildType.java.srcDirs- defaults to
sourceSets.$buildType.resources.srcDirs- defaults to
sourceSets.test.java.srcDirs- defaults to
sourceSets.test$Flavor.java.srcDirs- defaults to
dependencies.compile- compile time dependencies for all applications.
The source tree contains the following:
gradledirectory contains the plugin implementation.
testapps/basicdirectory contains a simple application that follows the conventions
testapps/customizeddirectory contains an application with some custom build types, product flavors and other customizations.
testapps/multiprojectdirectory contains an application composed from several Gradle projects.
To build the plugin, run
To import the plugin into the IDE, run
./gradlew idea or
To build a test application:
local.propertiesfile 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 tasksto see the tasks that are available.
You can also run these tasks:
assemble- builds all combinations of build type and product flavor
assemble$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/sourcefrom resource directories (main-source-set, product-flavor-source-set, build-type-source-set)
Some other notes:
sourceSets.main.compileClasspathas the compile classpath for each variant. Could potentially also include