diff options
author | Xavier Ducrohet <xav@android.com> | 2010-04-28 15:35:12 -0700 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2010-04-28 15:35:12 -0700 |
commit | 9520e97f048059f5a0a20599d6f778786fe2acc9 (patch) | |
tree | d28b797424a6cbff6745da72ba9f04ba8d2c4157 | |
parent | 2f3041c9707ca3a196083318d299ba71ab9d5cce (diff) | |
download | sdk-9520e97f048059f5a0a20599d6f778786fe2acc9.zip sdk-9520e97f048059f5a0a20599d6f778786fe2acc9.tar.gz sdk-9520e97f048059f5a0a20599d6f778786fe2acc9.tar.bz2 |
Ant: Add customizable targets between the default ones.
Change-Id: I5f187584afb91814ccba4e984c4c45c24557aaae
-rw-r--r-- | files/ant_rules_r3.xml | 20 | ||||
-rw-r--r-- | templates/build.template | 74 |
2 files changed, 62 insertions, 32 deletions
diff --git a/files/ant_rules_r3.xml b/files/ant_rules_r3.xml index 82abb6d..76f54e4 100644 --- a/files/ant_rules_r3.xml +++ b/files/ant_rules_r3.xml @@ -81,7 +81,7 @@ <property name="out.release.package" location="${out.absolute.dir}/${ant.project.name}-release.apk" /> - <!-- set some property used for filtering/override. If those weren't defined + <!-- set some properties used for filtering/override. If those weren't defined before, then this will create them with empty values, which are then ignored by the custom tasks receiving them. --> <property name="version.code" value="" /> @@ -216,8 +216,12 @@ <mkdir dir="${out.classes.absolute.dir}" /> </target> + <!-- empty default pre-build target. Create a similar target in + your build.xml and it'll be called instead of this one. --> + <target name="-pre-build"/> + <!-- Generates the R.java file for this project's resources. --> - <target name="-resource-src" depends="-dirs"> + <target name="-resource-src" depends="-dirs, -pre-build"> <echo>Generating R.java / Manifest.java from the resources...</echo> <aaptexec executable="${aapt}" command="package" @@ -242,8 +246,12 @@ </apply> </target> + <!-- empty default pre-compile target. Create a similar target in + your build.xml and it'll be called instead of this one. --> + <target name="-pre-compile"/> + <!-- Compiles this project's .java files into .class files. --> - <target name="compile" depends="-resource-src, -aidl" + <target name="compile" depends="-resource-src, -aidl, -pre-compile" description="Compiles project's .java files into .class files"> <!-- If android rules are used for a test project, its classpath should include tested project's location --> @@ -270,8 +278,12 @@ </javac> </target> + <!-- empty default post-compile target. Create a similar target in + your build.xml and it'll be called instead of this one. --> + <target name="-post-compile"/> + <!-- Converts this project's .class files into .dex files --> - <target name="-dex" depends="compile"> + <target name="-dex" depends="compile, -post-compile"> <dex-helper /> </target> diff --git a/templates/build.template b/templates/build.template index 3959c57..549ce7c 100644 --- a/templates/build.template +++ b/templates/build.template @@ -1,40 +1,42 @@ <?xml version="1.0" encoding="UTF-8"?> <project name="PROJECT_NAME" default="help"> - <!-- The local.properties file is created and updated by the 'android' tool. - It contains the path to the SDK. It should *NOT* be checked in in Version - Control Systems. --> +<!-- The local.properties file is created and updated by the 'android' + tool. + It contains the path to the SDK. It should *NOT* be checked in in + Version Control Systems. --> <property file="local.properties" /> <!-- The build.properties file can be created by you and is never touched - by the 'android' tool. This is the place to change some of the default property values - used by the Ant rules. + by the 'android' tool. This is the place to change some of the + default property values used by the Ant rules. Here are some properties you may want to change/update: application.package - the name of your application package as defined in the manifest. Used by the - 'uninstall' rule. + The name of your application package as defined in the manifest. + Used by the 'uninstall' rule. source.dir - the name of the source directory. Default is 'src'. + The name of the source directory. Default is 'src'. out.dir - the name of the output directory. Default is 'bin'. + The name of the output directory. Default is 'bin'. - Properties related to the SDK location or the project target should be updated - using the 'android' tool with the 'update' action. + Properties related to the SDK location or the project target should + be updated using the 'android' tool with the 'update' action. - This file is an integral part of the build system for your application and - should be checked in in Version Control Systems. + This file is an integral part of the build system for your + application and should be checked in in Version Control Systems. --> <property file="build.properties" /> - <!-- The default.properties file is created and updated by the 'android' tool, as well - as ADT. - This file is an integral part of the build system for your application and - should be checked in in Version Control Systems. --> + <!-- The default.properties file is created and updated by the 'android' + tool, as well as ADT. + This file is an integral part of the build system for your + application and should be checked in in Version Control Systems. --> <property file="default.properties" /> - <!-- Custom Android task to deal with the project target, and import the proper rules. + <!-- Custom Android task to deal with the project target, and import the + proper rules. This requires ant 1.6.0 or above. --> <path id="android.antlibs"> <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" /> @@ -48,19 +50,35 @@ classname="com.android.ant.SetupTask" classpathref="android.antlibs" /> - <!-- Execute the Android Setup task that will setup some properties specific to the target, - and import the build rules files. +<!-- extension targets. Uncomment the ones where you want to do custom work + in between standard targets --> +<!-- + <target name="-pre-build"> + </target> + <target name="-pre-compile"> + </target> + <target name="-post-compile"> + </target> +--> - The rules file is imported from - <SDK>/platforms/<target_platform>/templates/android_rules.xml - To customize some build steps for your project: - - copy the content of the main node <project> from android_rules.xml - - paste it in this build.xml below the <setup /> task. - - disable the import by changing the setup task below to <setup import="false" /> + <!-- Execute the Android Setup task that will setup some properties + specific to the target, and import the build rules files. + + The rules file is imported from + <SDK>/platforms/<target_platform>/ant/ant_rules_r#.xml - This will ensure that the properties are setup correctly but that your customized - build steps are used. + To customize existing targets, there are two options: + - Customize only one target: + - copy/paste the target into this file, *before* the + <setup> task. + - customize it to your needs. + - Customize the whole script. + - copy/paste the content of the rules files (minus the top node) + into this file, *after* the <setup> task + - disable the import of the rules by changing the setup task + below to <setup import="false" />. + - customize to your needs. --> <setup /> |