aboutsummaryrefslogtreecommitdiffstats
path: root/files
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2010-02-03 11:52:04 -0800
committerXavier Ducrohet <xav@android.com>2010-02-10 10:29:53 -0800
commit7bfc74613e9bced3f1b6291280e5cc80a5f5954a (patch)
tree7eaa9b5680deb9e39570cbe94bd5642b4dc3a64f /files
parentb62b85a33ea02907d8929cf2d977892f61417a6a (diff)
downloadsdk-7bfc74613e9bced3f1b6291280e5cc80a5f5954a.zip
sdk-7bfc74613e9bced3f1b6291280e5cc80a5f5954a.tar.gz
sdk-7bfc74613e9bced3f1b6291280e5cc80a5f5954a.tar.bz2
Add support for library project in the Ant build system.
new build rules file for library only. Should probably extract the parts that are common to this and the default rules file. SetupTask now sets up some properties and Path reference based on the libraries. They are used by: - aapt task (now also used for the generation of R.java) which use all the res folders of the main project and the libraries, and generate an R class for the project and the libraries. - javac which compiles the src/ folders of the libraries. Bug: 2294012 Change-Id: Ie550dcf0ba8ea57696ebb1c2a61d4c6d73307bdf
Diffstat (limited to 'files')
-rw-r--r--files/android_lib_rules.xml154
-rw-r--r--files/android_rules.xml36
2 files changed, 170 insertions, 20 deletions
diff --git a/files/android_lib_rules.xml b/files/android_lib_rules.xml
new file mode 100644
index 0000000..a6fb04d
--- /dev/null
+++ b/files/android_lib_rules.xml
@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="android_rules" default="debug">
+
+ <!--
+ This rules file is meant to be imported by the custom Ant task:
+ com.android.ant.SetupTask
+
+ The following properties are put in place by the importing task:
+ android.jar, android.aidl, aapt, aidl, and dx
+
+ Additionnaly, the task sets up the following classpath reference:
+ android.target.classpath
+ This is used by the compiler task as the boot classpath.
+ -->
+
+ <!-- Custom tasks -->
+ <taskdef name="aaptexec"
+ classname="com.android.ant.AaptExecLoopTask"
+ classpathref="android.antlibs" />
+
+ <taskdef name="xpath"
+ classname="com.android.ant.XPathTask"
+ classpathref="android.antlibs" />
+
+ <!-- Properties -->
+
+ <!-- Tells adb which device to target. You can change this from the command line
+ by invoking "ant -Dadb.device.arg=-d" for device "ant -Dadb.device.arg=-e" for
+ the emulator. -->
+ <property name="adb.device.arg" value="" />
+
+ <property name="android.tools.dir" location="${sdk.dir}/tools" />
+ <!-- Name of the application package extracted from manifest file -->
+ <xpath input="AndroidManifest.xml" expression="/manifest/@package"
+ output="manifest.package" />
+
+ <!-- Input directories -->
+ <property name="source.dir" value="src" />
+ <property name="source.absolute.dir" location="${source.dir}" />
+ <property name="gen.dir" value="gen" />
+ <property name="gen.absolute.dir" location="${gen.dir}" />
+ <property name="resource.dir" value="res" />
+ <property name="resource.absolute.dir" location="${resource.dir}" />
+ <property name="asset.dir" value="assets" />
+ <property name="asset.absolute.dir" location="${asset.dir}" />
+
+ <!-- Directory for the third party java libraries -->
+ <property name="external.libs.dir" value="libs" />
+ <property name="external.libs.absolute.dir" location="${external.libs.dir}" />
+
+ <!-- Directory for the native libraries -->
+ <property name="native.libs.dir" value="libs" />
+ <property name="native.libs.absolute.dir" location="${native.libs.dir}" />
+
+ <!-- Output directories -->
+ <property name="out.dir" value="bin" />
+ <property name="out.absolute.dir" location="${out.dir}" />
+ <property name="out.classes.dir" value="${out.absolute.dir}/classes" />
+ <property name="out.classes.absolute.dir" location="${out.classes.dir}" />
+
+ <!-- Verbosity -->
+ <property name="verbose" value="false" />
+ <!-- This is needed by emma as it uses multilevel verbosity instead of simple 'true' or 'false'
+ The property 'verbosity' is not user configurable and depends exclusively on 'verbose'
+ value.-->
+ <condition property="verbosity" value="verbose" else="quiet">
+ <istrue value="${verbose}" />
+ </condition>
+
+ <!-- Tools -->
+ <condition property="exe" value=".exe" else=""><os family="windows" /></condition>
+
+ <!-- Emma configuration -->
+ <property name="emma.dir" value="${sdk.dir}/tools/lib" />
+ <path id="emma.lib">
+ <pathelement location="${emma.dir}/emma.jar" />
+ <pathelement location="${emma.dir}/emma_ant.jar" />
+ </path>
+ <taskdef resource="emma_ant.properties" classpathref="emma.lib" />
+ <!-- End of emma configuration -->
+
+ <!-- Rules -->
+
+ <!-- Creates the output directories if they don't exist yet. -->
+ <target name="-dirs">
+ <echo>Creating output directories if needed...</echo>
+ <mkdir dir="${resource.absolute.dir}" />
+ <mkdir dir="${external.libs.absolute.dir}" />
+ <mkdir dir="${gen.absolute.dir}" />
+ <mkdir dir="${out.absolute.dir}" />
+ <mkdir dir="${out.classes.absolute.dir}" />
+ </target>
+
+ <!-- Generates the R.java file for this project's resources. -->
+ <target name="-resource-src" depends="-dirs">
+ <echo>Generating R.java / Manifest.java from the resources...</echo>
+ <aaptexec executable="${aapt}"
+ command="package"
+ verbose="${verbose}"
+ manifest="AndroidManifest.xml"
+ androidjar="${android.jar}"
+ rfolder="${gen.absolute.dir}">
+ <res path="${resource.absolute.dir}" />
+ </aaptexec>
+ </target>
+
+ <!-- Generates java classes from .aidl files. -->
+ <target name="-aidl" depends="-dirs">
+ <echo>Compiling aidl files into Java classes...</echo>
+ <apply executable="${aidl}" failonerror="true">
+ <arg value="-p${android.aidl}" />
+ <arg value="-I${source.absolute.dir}" />
+ <arg value="-o${gen.absolute.dir}" />
+ <fileset dir="${source.absolute.dir}">
+ <include name="**/*.aidl" />
+ </fileset>
+ </apply>
+ </target>
+
+ <!-- Compiles this project's .java files into .class files. -->
+ <target name="compile" depends="-resource-src, -aidl"
+ 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 -->
+ <condition property="extensible.classpath"
+ value="${tested.project.absolute.dir}/bin/classes" else=".">
+ <isset property="tested.project.absolute.dir" />
+ </condition>
+ <javac encoding="ascii" target="1.5" debug="true" extdirs=""
+ destdir="${out.classes.absolute.dir}"
+ bootclasspathref="android.target.classpath"
+ verbose="${verbose}" classpath="${extensible.classpath}">
+ <src path="${source.absolute.dir}" />
+ <src path="${gen.absolute.dir}" />
+ <classpath>
+ <fileset dir="${external.libs.absolute.dir}" includes="*.jar" />
+ </classpath>
+ </javac>
+ </target>
+
+ <target name="clean" description="Removes output files created by other targets.">
+ <delete dir="${out.absolute.dir}" verbose="${verbose}" />
+ <delete dir="${gen.absolute.dir}" verbose="${verbose}" />
+ </target>
+
+ <target name="help">
+ <!-- displays starts at col 13
+ |13 80| -->
+ <echo>Android Ant Build. Available targets:</echo>
+ <echo> help: Displays this help.</echo>
+ <echo> clean: Removes output files created by other targets.</echo>
+ <echo> compile: Compiles project's .java files into .class files.</echo>
+ </target>
+</project>
diff --git a/files/android_rules.xml b/files/android_rules.xml
index a61bf16..3d9cb19 100644
--- a/files/android_rules.xml
+++ b/files/android_rules.xml
@@ -3,7 +3,7 @@
<!--
This rules file is meant to be imported by the custom Ant task:
- com.android.ant.AndroidInitTask
+ com.android.ant.SetupTask
The following properties are put in place by the importing task:
android.jar, android.aidl, aapt, aidl, and dx
@@ -86,7 +86,7 @@
<condition property="verbosity" value="verbose" else="quiet">
<istrue value="${verbose}" />
</condition>
- <!-- This is needed to switch verbosity of zipalign and aapt. Depends exclusively on 'verbose'
+ <!-- This is needed to switch verbosity of zipalign. Depends exclusively on 'verbose'
-->
<condition property="v.option" value="-v" else="">
<istrue value="${verbose}" />
@@ -118,8 +118,7 @@
<element name="external-libs" optional="yes" />
<element name="extra-parameters" optional="yes" />
<sequential>
- <echo>Converting compiled files and external libraries into ${intermediate.dex.file}...
- </echo>
+ <echo>Converting compiled files and external libraries into ${intermediate.dex.file}...</echo>
<apply executable="${dx}" failonerror="true" parallel="true">
<arg value="--dex" />
<arg value="--output=${intermediate.dex.file}" />
@@ -154,6 +153,7 @@
verbose="${verbose}">
<file path="${intermediate.dex.file}" />
<sourcefolder path="${source.absolute.dir}" />
+ <sourcefolder refid="android.libraries.src" />
<nativefolder path="${native.libs.absolute.dir}" />
<jarfolder path="${external.libs.absolute.dir}" />
<extra-jars/>
@@ -207,19 +207,14 @@
<!-- Generates the R.java file for this project's resources. -->
<target name="-resource-src" depends="-dirs">
<echo>Generating R.java / Manifest.java from the resources...</echo>
- <exec executable="${aapt}" failonerror="true">
- <arg value="package" />
- <arg line="${v.option}" />
- <arg value="-m" />
- <arg value="-J" />
- <arg path="${gen.absolute.dir}" />
- <arg value="-M" />
- <arg path="AndroidManifest.xml" />
- <arg value="-S" />
- <arg path="${resource.absolute.dir}" />
- <arg value="-I" />
- <arg path="${android.jar}" />
- </exec>
+ <aaptexec executable="${aapt}"
+ command="package"
+ verbose="${verbose}"
+ manifest="AndroidManifest.xml"
+ androidjar="${android.jar}"
+ rfolder="${gen.absolute.dir}">
+ <res path="${resource.absolute.dir}" />
+ </aaptexec>
</target>
<!-- Generates java classes from .aidl files. -->
@@ -250,6 +245,7 @@
verbose="${verbose}" classpath="${extensible.classpath}">
<src path="${source.absolute.dir}" />
<src path="${gen.absolute.dir}" />
+ <src refid="android.libraries.src" />
<classpath>
<fileset dir="${external.libs.absolute.dir}" includes="*.jar" />
</classpath>
@@ -271,11 +267,11 @@
<aaptexec executable="${aapt}"
command="package"
manifest="AndroidManifest.xml"
- resources="${resource.absolute.dir}"
assets="${asset.absolute.dir}"
androidjar="${android.jar}"
- outfolder="${out.absolute.dir}"
- basename="${ant.project.name}">
+ apkfolder="${out.absolute.dir}"
+ apkbasename="${ant.project.name}">
+ <res path="${resource.absolute.dir}" />
<!-- <nocompress /> forces no compression on any files in assets or res/raw -->
<!-- <nocompress extension="xml" /> forces no compression on specific file extensions in assets and res/raw -->
</aaptexec>