Merge the new Ant script rules and template from Eclair (do not merge)
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
android:versionCode="1"
|
android:versionCode="1"
|
||||||
android:versionName="1.0">
|
android:versionName="1.0">
|
||||||
<application android:label="@string/app_name">
|
<application android:label="@string/app_name">
|
||||||
<activity android:name=".ACTIVITY_NAME"
|
<activity android:name="ACTIVITY_ENTRY_NAME"
|
||||||
android:label="@string/app_name">
|
android:label="@string/app_name">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|||||||
@@ -17,5 +17,5 @@
|
|||||||
-->
|
-->
|
||||||
<instrumentation android:name="android.test.InstrumentationTestRunner"
|
<instrumentation android:name="android.test.InstrumentationTestRunner"
|
||||||
android:targetPackage="PACKAGE"
|
android:targetPackage="PACKAGE"
|
||||||
android:label="Tests for ACTIVITY_NAME"/>
|
android:label="Tests for PACKAGE"/>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
@@ -5,22 +5,22 @@ THIS FILE IS CURRENTLY BROKEN AND SHOULD NOT BE USED.
|
|||||||
-->
|
-->
|
||||||
<project name="alias_rules" default="package">
|
<project name="alias_rules" default="package">
|
||||||
|
|
||||||
<!-- No user servicable parts below. -->
|
<!-- No user serviceable parts below. -->
|
||||||
|
|
||||||
<!-- Input directories -->
|
<!-- Input directories -->
|
||||||
<property name="resource-dir" value="res" />
|
<property name="resource.dir" value="res" />
|
||||||
|
|
||||||
<!-- The final package file to generate -->
|
<!-- The final package file to generate -->
|
||||||
<property name="out-package" value="${ant.project.name}.apk" />
|
<property name="out.package" value="${ant.project.name}.apk" />
|
||||||
|
|
||||||
<!-- Tools -->
|
<!-- Tools -->
|
||||||
<condition property="aapt" value="${android-tools}/aapt.exe" else="${android-tools}/aapt" >
|
<condition property="aapt" value="${android.tools.dir}/aapt.exe" else="${android.tools.dir}/aapt">
|
||||||
<os family="windows" />
|
<os family="windows" />
|
||||||
</condition>
|
</condition>
|
||||||
<condition property="adb" value="${android-tools}/adb.exe" else="${android-tools}/adb" >
|
<condition property="adb" value="${android.tools.dir}/adb.exe" else="${android.tools.dir}/adb">
|
||||||
<os family="windows" />
|
<os family="windows" />
|
||||||
</condition>
|
</condition>
|
||||||
<property name="android-jar" value="${sdk-folder}/android.jar" />
|
<property name="android.jar" value="${sdk.dir}/android.jar" />
|
||||||
|
|
||||||
<!-- Rules -->
|
<!-- Rules -->
|
||||||
|
|
||||||
@@ -33,11 +33,11 @@ THIS FILE IS CURRENTLY BROKEN AND SHOULD NOT BE USED.
|
|||||||
<arg value="-M" />
|
<arg value="-M" />
|
||||||
<arg value="AndroidManifest.xml" />
|
<arg value="AndroidManifest.xml" />
|
||||||
<arg value="-S" />
|
<arg value="-S" />
|
||||||
<arg value="${resource-dir}" />
|
<arg value="${resource.dir}" />
|
||||||
<arg value="-I" />
|
<arg value="-I" />
|
||||||
<arg value="${android-jar}" />
|
<arg value="${android.jar}" />
|
||||||
<arg value="-F" />
|
<arg value="-F" />
|
||||||
<arg value="${out-package}" />
|
<arg value="${out.package}" />
|
||||||
</exec>
|
</exec>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ THIS FILE IS CURRENTLY BROKEN AND SHOULD NOT BE USED.
|
|||||||
<echo>Sending package to default emulator...</echo>
|
<echo>Sending package to default emulator...</echo>
|
||||||
<exec executable="${adb}" failonerror="true">
|
<exec executable="${adb}" failonerror="true">
|
||||||
<arg value="install" />
|
<arg value="install" />
|
||||||
<arg value="${out-package}" />
|
<arg value="${out.package}" />
|
||||||
</exec>
|
</exec>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
com.android.ant.AndroidInitTask
|
com.android.ant.AndroidInitTask
|
||||||
|
|
||||||
The following properties are put in place by the importing task:
|
The following properties are put in place by the importing task:
|
||||||
android-jar, android-aidl, aapt, aidl, and dx
|
android.jar, android.aidl, aapt, aidl, and dx
|
||||||
|
|
||||||
Additionnaly, the task sets up the following classpath reference:
|
Additionnaly, the task sets up the following classpath reference:
|
||||||
android.target.classpath
|
android.target.classpath
|
||||||
@@ -22,178 +22,279 @@
|
|||||||
classname="com.android.ant.ApkBuilderTask"
|
classname="com.android.ant.ApkBuilderTask"
|
||||||
classpathref="android.antlibs" />
|
classpathref="android.antlibs" />
|
||||||
|
|
||||||
|
<taskdef name="xpath"
|
||||||
|
classname="com.android.ant.XPathTask"
|
||||||
|
classpathref="android.antlibs" />
|
||||||
|
|
||||||
<!-- Properties -->
|
<!-- Properties -->
|
||||||
|
|
||||||
<property name="android-tools" value="${sdk-location}/tools" />
|
<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 -->
|
<!-- Input directories -->
|
||||||
<property name="source-folder" value="src" />
|
<property name="source.dir" value="src" />
|
||||||
<property name="gen-folder" value="gen" />
|
<property name="source.absolute.dir" location="${source.dir}" />
|
||||||
<property name="resource-folder" value="res" />
|
<property name="gen.dir" value="gen" />
|
||||||
<property name="asset-folder" value="assets" />
|
<property name="gen.absolute.dir" location="${gen.dir}" />
|
||||||
<property name="source-location" value="${basedir}/${source-folder}" />
|
<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}" />
|
||||||
|
|
||||||
<!-- folder for the 3rd party java libraries -->
|
<!-- Directory for the third party java libraries -->
|
||||||
<property name="external-libs-folder" value="libs" />
|
<property name="external.libs.dir" value="libs" />
|
||||||
|
<property name="external.libs.absolute.dir" location="${external.libs.dir}" />
|
||||||
|
|
||||||
<!-- folder for the native libraries -->
|
<!-- Directory for the native libraries -->
|
||||||
<property name="native-libs-folder" value="libs" />
|
<property name="native.libs.dir" value="libs" />
|
||||||
|
<property name="native.libs.absolute.dir" location="${native.libs.dir}" />
|
||||||
|
|
||||||
<!-- Output directories -->
|
<!-- Output directories -->
|
||||||
<property name="gen-folder" value="gen" />
|
<property name="out.dir" value="bin" />
|
||||||
<property name="out-folder" value="bin" />
|
<property name="out.absolute.dir" location="${out.dir}" />
|
||||||
<property name="out-classes" value="${out-folder}/classes" />
|
<property name="out.classes.dir" value="${out.absolute.dir}/classes" />
|
||||||
<property name="out-classes-location" value="${basedir}/${out-classes}"/>
|
<property name="out.classes.absolute.dir" location="${out.classes.dir}" />
|
||||||
<!-- out folders for a parent project if this project is an instrumentation project -->
|
|
||||||
<property name="main-out-folder" value="../${out-folder}" />
|
|
||||||
<property name="main-out-classes" value="${main-out-folder}/classes"/>
|
|
||||||
|
|
||||||
<!-- Intermediate files -->
|
<!-- Intermediate files -->
|
||||||
<property name="dex-file" value="classes.dex" />
|
<property name="dex.file.name" value="classes.dex" />
|
||||||
<property name="intermediate-dex" value="${out-folder}/${dex-file}" />
|
<property name="intermediate.dex.file" location="${out.absolute.dir}/${dex.file.name}" />
|
||||||
<!-- dx does not properly support incorrect / or \ based on the platform
|
|
||||||
and Ant cannot convert them because the parameter is not a valid path.
|
|
||||||
Because of this we have to compute different paths depending on the platform. -->
|
|
||||||
<condition property="intermediate-dex-location"
|
|
||||||
value="${basedir}\${intermediate-dex}"
|
|
||||||
else="${basedir}/${intermediate-dex}" >
|
|
||||||
<os family="windows"/>
|
|
||||||
</condition>
|
|
||||||
|
|
||||||
<!-- The final package file to generate -->
|
<!-- The final package file to generate -->
|
||||||
<property name="out-debug-unaligned-package" value="${out-folder}/${ant.project.name}-debug-unaligned.apk"/>
|
<property name="out.debug.unaligned.package"
|
||||||
<property name="out-debug-package" value="${out-folder}/${ant.project.name}-debug.apk"/>
|
location="${out.absolute.dir}/${ant.project.name}-debug-unaligned.apk" />
|
||||||
<property name="out-unsigned-package" value="${out-folder}/${ant.project.name}-unsigned.apk"/>
|
<property name="out.debug.package"
|
||||||
<property name="out-unaligned-package" value="${out-folder}/${ant.project.name}-unaligned.apk"/>
|
location="${out.absolute.dir}/${ant.project.name}-debug.apk" />
|
||||||
<property name="out-release-package" value="${out-folder}/${ant.project.name}-release.apk"/>
|
<property name="out.unsigned.package"
|
||||||
|
location="${out.absolute.dir}/${ant.project.name}-unsigned.apk" />
|
||||||
|
<property name="out.unaligned.package"
|
||||||
|
location="${out.absolute.dir}/${ant.project.name}-unaligned.apk" />
|
||||||
|
<property name="out.release.package"
|
||||||
|
location="${out.absolute.dir}/${ant.project.name}-release.apk" />
|
||||||
|
|
||||||
|
<!-- 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>
|
||||||
|
<!-- This is needed to switch verbosity of zipalign and aapt. Depends exclusively on 'verbose'
|
||||||
|
-->
|
||||||
|
<condition property="v.option" value="-v" else="">
|
||||||
|
<istrue value="${verbose}" />
|
||||||
|
</condition>
|
||||||
|
<!-- This is needed to switch verbosity of dx. Depends exclusively on 'verbose' -->
|
||||||
|
<condition property="verbose.option" value="--verbose" else="">
|
||||||
|
<istrue value="${verbose}" />
|
||||||
|
</condition>
|
||||||
|
|
||||||
<!-- Tools -->
|
<!-- Tools -->
|
||||||
<condition property="exe" value=".exe" else=""><os family="windows" /></condition>
|
<condition property="exe" value=".exe" else=""><os family="windows" /></condition>
|
||||||
<property name="adb" value="${android-tools}/adb${exe}"/>
|
<property name="adb" location="${android.tools.dir}/adb${exe}" />
|
||||||
<property name="zipalign" value="${android-tools}/zipalign${exe}" />
|
<property name="zipalign" location="${android.tools.dir}/zipalign${exe}" />
|
||||||
|
|
||||||
<!-- rules -->
|
<!-- 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 -->
|
||||||
|
|
||||||
<!-- Create the output directories if they don't exist yet. -->
|
<!-- Macros -->
|
||||||
<target name="dirs">
|
|
||||||
|
<!-- Configurable macro, which allows to pass as parameters output directory,
|
||||||
|
output dex filename and external libraries to dex (optional) -->
|
||||||
|
<macrodef name="dex-helper">
|
||||||
|
<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>
|
||||||
|
<apply executable="${dx}" failonerror="true" parallel="true">
|
||||||
|
<arg value="--dex" />
|
||||||
|
<arg value="--output=${intermediate.dex.file}" />
|
||||||
|
<extra-parameters />
|
||||||
|
<arg line="${verbose.option}" />
|
||||||
|
<arg path="${out.classes.absolute.dir}" />
|
||||||
|
<fileset dir="${external.libs.absolute.dir}" includes="*.jar" />
|
||||||
|
<external-libs />
|
||||||
|
</apply>
|
||||||
|
</sequential>
|
||||||
|
</macrodef>
|
||||||
|
|
||||||
|
<!-- This is macro that enable passing variable list of external jar files to ApkBuilder
|
||||||
|
Example of use:
|
||||||
|
<package-helper>
|
||||||
|
<extra-jars>
|
||||||
|
<jarfolder path="my_jars" />
|
||||||
|
<jarfile path="foo/bar.jar" />
|
||||||
|
<jarfolder path="your_jars" />
|
||||||
|
</extra-jars>
|
||||||
|
</package-helper> -->
|
||||||
|
<macrodef name="package-helper">
|
||||||
|
<attribute name="sign.package" />
|
||||||
|
<element name="extra-jars" optional="yes" />
|
||||||
|
<sequential>
|
||||||
|
<apkbuilder
|
||||||
|
outfolder="${out.absolute.dir}"
|
||||||
|
basename="${ant.project.name}"
|
||||||
|
signed="@{sign.package}"
|
||||||
|
verbose="${verbose}">
|
||||||
|
<file path="${intermediate.dex.file}" />
|
||||||
|
<sourcefolder path="${source.absolute.dir}" />
|
||||||
|
<nativefolder path="${native.libs.absolute.dir}" />
|
||||||
|
<jarfolder path="${external.libs.absolute.dir}" />
|
||||||
|
<extra-jars/>
|
||||||
|
</apkbuilder>
|
||||||
|
</sequential>
|
||||||
|
</macrodef>
|
||||||
|
|
||||||
|
<!-- This is macro which zipaligns in.package and outputs it to out.package. Used by targets
|
||||||
|
debug, -debug-with-emma and release.-->
|
||||||
|
<macrodef name="zipalign-helper">
|
||||||
|
<attribute name="in.package" />
|
||||||
|
<attribute name="out.package" />
|
||||||
|
<sequential>
|
||||||
|
<echo>Running zip align on final apk...</echo>
|
||||||
|
<exec executable="${zipalign}" failonerror="true">
|
||||||
|
<arg line="${v.option}" />
|
||||||
|
<arg value="-f" />
|
||||||
|
<arg value="4" />
|
||||||
|
<arg path="@{in.package}" />
|
||||||
|
<arg path="@{out.package}" />
|
||||||
|
</exec>
|
||||||
|
</sequential>
|
||||||
|
</macrodef>
|
||||||
|
|
||||||
|
<!-- This is macro used only for sharing code among two targets, -install and
|
||||||
|
-install-with-emma which do exactly the same but differ in dependencies -->
|
||||||
|
<macrodef name="install-helper">
|
||||||
|
<sequential>
|
||||||
|
<echo>Installing ${out.debug.package} onto default emulator or device...</echo>
|
||||||
|
<exec executable="${adb}" failonerror="true">
|
||||||
|
<arg value="install" />
|
||||||
|
<arg value="-r" />
|
||||||
|
<arg path="${out.debug.package}" />
|
||||||
|
</exec>
|
||||||
|
</sequential>
|
||||||
|
</macrodef>
|
||||||
|
|
||||||
|
<!-- Rules -->
|
||||||
|
|
||||||
|
<!-- Creates the output directories if they don't exist yet. -->
|
||||||
|
<target name="-dirs">
|
||||||
<echo>Creating output directories if needed...</echo>
|
<echo>Creating output directories if needed...</echo>
|
||||||
<mkdir dir="${resource-folder}" />
|
<mkdir dir="${resource.absolute.dir}" />
|
||||||
<mkdir dir="${external-libs-folder}" />
|
<mkdir dir="${external.libs.absolute.dir}" />
|
||||||
<mkdir dir="${gen-folder}" />
|
<mkdir dir="${gen.absolute.dir}" />
|
||||||
<mkdir dir="${out-folder}" />
|
<mkdir dir="${out.absolute.dir}" />
|
||||||
<mkdir dir="${out-classes}" />
|
<mkdir dir="${out.classes.absolute.dir}" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- Generate the R.java file for this project's resources. -->
|
<!-- Generates the R.java file for this project's resources. -->
|
||||||
<target name="resource-src" depends="dirs">
|
<target name="-resource-src" depends="-dirs">
|
||||||
<echo>Generating R.java / Manifest.java from the resources...</echo>
|
<echo>Generating R.java / Manifest.java from the resources...</echo>
|
||||||
<exec executable="${aapt}" failonerror="true">
|
<exec executable="${aapt}" failonerror="true">
|
||||||
<arg value="package" />
|
<arg value="package" />
|
||||||
|
<arg line="${v.option}" />
|
||||||
<arg value="-m" />
|
<arg value="-m" />
|
||||||
<arg value="-J" />
|
<arg value="-J" />
|
||||||
<arg path="${gen-folder}" />
|
<arg path="${gen.absolute.dir}" />
|
||||||
<arg value="-M" />
|
<arg value="-M" />
|
||||||
<arg path="AndroidManifest.xml" />
|
<arg path="AndroidManifest.xml" />
|
||||||
<arg value="-S" />
|
<arg value="-S" />
|
||||||
<arg path="${resource-folder}" />
|
<arg path="${resource.absolute.dir}" />
|
||||||
<arg value="-I" />
|
<arg value="-I" />
|
||||||
<arg path="${android-jar}" />
|
<arg path="${android.jar}" />
|
||||||
</exec>
|
</exec>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- Generate java classes from .aidl files. -->
|
<!-- Generates java classes from .aidl files. -->
|
||||||
<target name="aidl" depends="dirs">
|
<target name="-aidl" depends="-dirs">
|
||||||
<echo>Compiling aidl files into Java classes...</echo>
|
<echo>Compiling aidl files into Java classes...</echo>
|
||||||
<apply executable="${aidl}" failonerror="true">
|
<apply executable="${aidl}" failonerror="true">
|
||||||
<arg value="-p${android-aidl}" />
|
<arg value="-p${android.aidl}" />
|
||||||
<arg value="-I${source-folder}" />
|
<arg value="-I${source.absolute.dir}" />
|
||||||
<arg value="-o${gen-folder}" />
|
<arg value="-o${gen.absolute.dir}" />
|
||||||
<fileset dir="${source-folder}">
|
<fileset dir="${source.absolute.dir}">
|
||||||
<include name="**/*.aidl" />
|
<include name="**/*.aidl" />
|
||||||
</fileset>
|
</fileset>
|
||||||
</apply>
|
</apply>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- Compile this project's .java files into .class files. -->
|
<!-- Compiles this project's .java files into .class files. -->
|
||||||
<target name="compile" depends="resource-src, aidl">
|
<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=""
|
<javac encoding="ascii" target="1.5" debug="true" extdirs=""
|
||||||
destdir="${out-classes}"
|
destdir="${out.classes.absolute.dir}"
|
||||||
bootclasspathref="android.target.classpath">
|
bootclasspathref="android.target.classpath"
|
||||||
<src path="${source-folder}" />
|
verbose="${verbose}" classpath="${extensible.classpath}">
|
||||||
<src path="${gen-folder}" />
|
<src path="${source.absolute.dir}" />
|
||||||
|
<src path="${gen.absolute.dir}" />
|
||||||
<classpath>
|
<classpath>
|
||||||
<fileset dir="${external-libs-folder}" includes="*.jar"/>
|
<fileset dir="${external.libs.absolute.dir}" includes="*.jar" />
|
||||||
<pathelement path="${main-out-classes}"/>
|
|
||||||
</classpath>
|
</classpath>
|
||||||
</javac>
|
</javac>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- Convert this project's .class files into .dex files. -->
|
<!-- Converts this project's .class files into .dex files -->
|
||||||
<target name="dex" depends="compile">
|
<target name="-dex" depends="compile">
|
||||||
<echo>Converting compiled files and external libraries into ${out-folder}/${dex-file}...</echo>
|
<dex-helper />
|
||||||
<apply executable="${dx}" failonerror="true" parallel="true">
|
|
||||||
<arg value="--dex" />
|
|
||||||
<arg value="--output=${intermediate-dex-location}" />
|
|
||||||
<arg path="${out-classes-location}" />
|
|
||||||
<fileset dir="${external-libs-folder}" includes="*.jar"/>
|
|
||||||
</apply>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- Put the project's resources into the output package file
|
<!-- Puts the project's resources into the output package file
|
||||||
This actually can create multiple resource package in case
|
This actually can create multiple resource package in case
|
||||||
Some custom apk with specific configuration have been
|
Some custom apk with specific configuration have been
|
||||||
declared in default.properties.
|
declared in default.properties.
|
||||||
-->
|
-->
|
||||||
<target name="package-resources">
|
<target name="-package-resources">
|
||||||
<echo>Packaging resources</echo>
|
<echo>Packaging resources</echo>
|
||||||
<aaptexec executable="${aapt}"
|
<aaptexec executable="${aapt}"
|
||||||
command="package"
|
command="package"
|
||||||
manifest="AndroidManifest.xml"
|
manifest="AndroidManifest.xml"
|
||||||
resources="${resource-folder}"
|
resources="${resource.absolute.dir}"
|
||||||
assets="${asset-folder}"
|
assets="${asset.absolute.dir}"
|
||||||
androidjar="${android-jar}"
|
androidjar="${android.jar}"
|
||||||
outfolder="${out-folder}"
|
outfolder="${out.absolute.dir}"
|
||||||
basename="${ant.project.name}" />
|
basename="${ant.project.name}" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- Package the application and (maybe) sign it with a debug key.
|
<!-- Packages the application and sign it with a debug key. -->
|
||||||
This requires the property sign.package to be set to true or false. -->
|
<target name="-package-debug-sign" depends="-dex, -package-resources">
|
||||||
<target name="package">
|
<package-helper sign.package="true" />
|
||||||
<apkbuilder
|
|
||||||
outfolder="${out-folder}"
|
|
||||||
basename="${ant.project.name}"
|
|
||||||
signed="${sign.package}"
|
|
||||||
verbose="true">
|
|
||||||
<file path="${intermediate-dex}" />
|
|
||||||
<sourcefolder path="${source-folder}" />
|
|
||||||
<jarfolder path="${external-libs-folder}" />
|
|
||||||
<nativefolder path="${native-libs-folder}" />
|
|
||||||
</apkbuilder>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="no-sign">
|
<!-- Packages the application without signing it. -->
|
||||||
<property name="sign.package" value="false" />
|
<target name="-package-no-sign" depends="-dex, -package-resources">
|
||||||
|
<package-helper sign.package="false" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="debug-sign">
|
<target name="-compile-tested-if-test" if="tested.project.dir" unless="do.not.compile.again">
|
||||||
<property name="sign.package" value="true" />
|
<subant target="compile">
|
||||||
|
<fileset dir="${tested.project.absolute.dir}" includes="build.xml" />
|
||||||
|
</subant>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="debug" depends="dex, package-resources, debug-sign, package">
|
<!-- Builds debug output package, provided all the necessary files are already dexed -->
|
||||||
<echo>Running zip align on final apk...</echo>
|
<target name="debug" depends="-compile-tested-if-test, -package-debug-sign"
|
||||||
<exec executable="${zipalign}" failonerror="true">
|
description="Builds the application and signs it with a debug key.">
|
||||||
<arg value="-f" />
|
<zipalign-helper in.package="${out.debug.unaligned.package}"
|
||||||
<arg value="4" />
|
out.package="${out.debug.package}" />
|
||||||
<arg path="${out-debug-unaligned-package}" />
|
<echo>Debug Package: ${out.debug.package}</echo>
|
||||||
<arg path="${out-debug-package}" />
|
|
||||||
</exec>
|
|
||||||
<echo>Debug Package: ${out-debug-package}</echo>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="release-package" depends="dex, package-resources, no-sign, package">
|
<target name="-release-check">
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="release.check">
|
|
||||||
<condition property="release.sign">
|
<condition property="release.sign">
|
||||||
<and>
|
<and>
|
||||||
<isset property="key.store" />
|
<isset property="key.store" />
|
||||||
@@ -201,80 +302,139 @@
|
|||||||
</and>
|
</and>
|
||||||
</condition>
|
</condition>
|
||||||
</target>
|
</target>
|
||||||
<target name="release.nosign" depends="release.check" unless="release.sign">
|
|
||||||
|
<target name="-release-nosign" depends="-release-check" unless="release.sign">
|
||||||
<echo>No key.store and key.alias properties found in build.properties.</echo>
|
<echo>No key.store and key.alias properties found in build.properties.</echo>
|
||||||
<echo>Please sign ${out-unsigned-package} manually</echo>
|
<echo>Please sign ${out.unsigned.package} manually</echo>
|
||||||
<echo>and run zipalign from the Android SDK tools.</echo>
|
<echo>and run zipalign from the Android SDK tools.</echo>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="release" depends="release-package, release.nosign" if="release.sign">
|
<target name="release" depends="-package-no-sign, -release-nosign" if="release.sign"
|
||||||
<!-- get passwords -->
|
description="Builds the application. The generated apk file must be signed before
|
||||||
|
it is published.">
|
||||||
|
<!-- Gets passwords -->
|
||||||
<input
|
<input
|
||||||
message="Please enter keystore password (store:${key.store}):"
|
message="Please enter keystore password (store:${key.store}):"
|
||||||
addproperty="key.store.password" />
|
addproperty="key.store.password" />
|
||||||
<input
|
<input
|
||||||
message="Please enter password for alias '${key.alias}':"
|
message="Please enter password for alias '${key.alias}':"
|
||||||
addproperty="key.alias.password" />
|
addproperty="key.alias.password" />
|
||||||
<!-- sign the APK -->
|
|
||||||
|
<!-- Signs the APK -->
|
||||||
<echo>Signing final apk...</echo>
|
<echo>Signing final apk...</echo>
|
||||||
<signjar
|
<signjar
|
||||||
jar="${out-unsigned-package}"
|
jar="${out.unsigned.package}"
|
||||||
signedjar="${out-unaligned-package}"
|
signedjar="${out.unaligned.package}"
|
||||||
keystore="${key.store}"
|
keystore="${key.store}"
|
||||||
storepass="${key.store.password}"
|
storepass="${key.store.password}"
|
||||||
alias="${key.alias}"
|
alias="${key.alias}"
|
||||||
keypass="${key.alias.password}"/>
|
keypass="${key.alias.password}"
|
||||||
<!-- zip align the APK -->
|
verbose="${verbose}" />
|
||||||
<echo>Running zip align on final apk...</echo>
|
|
||||||
<exec executable="${zipalign}" failonerror="true">
|
<!-- Zip aligns the APK -->
|
||||||
<arg value="-f" />
|
<zipalign-helper in.package="${out.unaligned.package}"
|
||||||
<arg value="4" />
|
out.package="${out.release.package}" />
|
||||||
<arg path="${out-unaligned-package}" />
|
<echo>Release Package: ${out.release.package}</echo>
|
||||||
<arg path="${out-release-package}" />
|
|
||||||
</exec>
|
|
||||||
<echo>Release Package: ${out-release-package}</echo>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- Install the package on the default emulator -->
|
<target name="install" depends="debug"
|
||||||
<target name="install" depends="debug">
|
description="Installs/reinstalls the debug package onto a running
|
||||||
<echo>Installing ${out-debug-package} onto default emulator...</echo>
|
emulator or device. If the application was previously installed,
|
||||||
<exec executable="${adb}" failonerror="true">
|
the signatures must match." >
|
||||||
<arg value="install" />
|
<install-helper />
|
||||||
<arg value="-r" />
|
|
||||||
<arg path="${out-debug-package}" />
|
|
||||||
</exec>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- Uinstall the package from the default emulator -->
|
<target name="-uninstall-check">
|
||||||
<target name="uninstall.check">
|
|
||||||
<condition property="uninstall.run">
|
<condition property="uninstall.run">
|
||||||
<isset property="application-package" />
|
<isset property="manifest.package" />
|
||||||
</condition>
|
</condition>
|
||||||
</target>
|
</target>
|
||||||
<target name="uninstall.error" depends="uninstall.check" unless="uninstall.run">
|
|
||||||
<echo>Unable to run 'ant unintall', application-package is not defined in build.properties</echo>
|
<target name="-uninstall-error" depends="-uninstall-check" unless="uninstall.run">
|
||||||
|
<echo>Unable to run 'ant uninstall', manifest.package property is not defined.
|
||||||
|
</echo>
|
||||||
</target>
|
</target>
|
||||||
<target name="uninstall" depends="uninstall.error" if="uninstall.run">
|
|
||||||
<echo>Uninstalling ${application-package} from the default emulator...</echo>
|
<!-- Uninstalls the package from the default emulator/device -->
|
||||||
|
<target name="uninstall" depends="-uninstall-error" if="uninstall.run"
|
||||||
|
description="Uninstalls the application from a running emulator or device.">
|
||||||
|
<echo>Uninstalling ${manifest.package} from the default emulator or device...</echo>
|
||||||
<exec executable="${adb}" failonerror="true">
|
<exec executable="${adb}" failonerror="true">
|
||||||
<arg value="uninstall" />
|
<arg value="uninstall" />
|
||||||
<arg value="${application-package}" />
|
<arg value="${manifest.package}" />
|
||||||
</exec>
|
</exec>
|
||||||
</target>
|
</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>
|
||||||
|
|
||||||
|
<!-- Targets for code-coverage measurement purposes, invoked from external file -->
|
||||||
|
|
||||||
|
<!-- Emma-instruments tested project classes (compiles the tested project if necessary)
|
||||||
|
and writes instrumented classes to ${instrumentation.absolute.dir}/classes -->
|
||||||
|
<target name="-emma-instrument" depends="compile">
|
||||||
|
<echo>Instrumenting classes from ${out.absolute.dir}/classes...</echo>
|
||||||
|
<!-- It only instruments class files, not any external libs -->
|
||||||
|
<emma enabled="true">
|
||||||
|
<instr verbosity="${verbosity}"
|
||||||
|
mode="overwrite"
|
||||||
|
instrpath="${out.absolute.dir}/classes"
|
||||||
|
outdir="${out.absolute.dir}/classes">
|
||||||
|
</instr>
|
||||||
|
<!-- TODO: exclusion filters on R*.class and allowing custom exclusion from
|
||||||
|
user defined file -->
|
||||||
|
</emma>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-dex-instrumented" depends="-emma-instrument">
|
||||||
|
<dex-helper>
|
||||||
|
<extra-parameters>
|
||||||
|
<arg value="--no-locals" />
|
||||||
|
</extra-parameters>
|
||||||
|
<external-libs>
|
||||||
|
<fileset file="${emma.dir}/emma_device.jar" />
|
||||||
|
</external-libs>
|
||||||
|
</dex-helper>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- Invoked from external files for code coverage purposes -->
|
||||||
|
<target name="-package-with-emma" depends="-dex-instrumented, -package-resources">
|
||||||
|
<package-helper sign.package="true">
|
||||||
|
<extra-jars>
|
||||||
|
<!-- Injected from external file -->
|
||||||
|
<jarfile path="${emma.dir}/emma_device.jar" />
|
||||||
|
</extra-jars>
|
||||||
|
</package-helper>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-debug-with-emma" depends="-package-with-emma">
|
||||||
|
<zipalign-helper in.package="${out.debug.unaligned.package}"
|
||||||
|
out.package="${out.debug.package}" />
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-install-with-emma" depends="-debug-with-emma">
|
||||||
|
<install-helper />
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- End of targets for code-coverage measurement purposes -->
|
||||||
|
|
||||||
<target name="help">
|
<target name="help">
|
||||||
<!-- displays starts at col 13
|
<!-- displays starts at col 13
|
||||||
|13 80| -->
|
|13 80| -->
|
||||||
<echo>Android Ant Build. Available targets:</echo>
|
<echo>Android Ant Build. Available targets:</echo>
|
||||||
<echo> help: Displays this help.</echo>
|
<echo> help: Displays this help.</echo>
|
||||||
<echo> debug: Builds the application and sign it with a debug key.</echo>
|
<echo> clean: Removes output files created by other targets.</echo>
|
||||||
|
<echo> compile: Compiles project's .java files into .class files.</echo>
|
||||||
|
<echo> debug: Builds the application and signs it with a debug key.</echo>
|
||||||
<echo> release: Builds the application. The generated apk file must be</echo>
|
<echo> release: Builds the application. The generated apk file must be</echo>
|
||||||
<echo> signed before it is published.</echo>
|
<echo> signed before it is published.</echo>
|
||||||
<echo> install: Installs/reinstall the debug package onto a running</echo>
|
<echo> install: Installs/reinstalls the debug package onto a running</echo>
|
||||||
<echo> emulator or device.</echo>
|
<echo> emulator or device.</echo>
|
||||||
<echo> If the application was previously installed, the</echo>
|
<echo> If the application was previously installed, the</echo>
|
||||||
<echo> signatures must match.</echo>
|
<echo> signatures must match.</echo>
|
||||||
<echo> uninstall: uninstall the application from a running emulator or</echo>
|
<echo> uninstall: Uninstalls the application from a running emulator or</echo>
|
||||||
<echo> device.</echo>
|
<echo> device.</echo>
|
||||||
</target>
|
</target>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
104
tools/scripts/android_test_rules.xml
Normal file
104
tools/scripts/android_test_rules.xml
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project name="android_test_rules" default="run-tests">
|
||||||
|
|
||||||
|
<import file="android_rules.xml" />
|
||||||
|
|
||||||
|
<property name="tested.project.absolute.dir" location="${tested.project.dir}" />
|
||||||
|
<property name="instrumentation.dir" value="instrumented" />
|
||||||
|
<property name="instrumentation.absolute.dir" location="${instrumentation.dir}" />
|
||||||
|
|
||||||
|
<property name="test.runner" value="android.test.InstrumentationTestRunner" />
|
||||||
|
<!-- Application package of the tested project extracted from its manifest file -->
|
||||||
|
<xpath input="${tested.project.absolute.dir}/AndroidManifest.xml"
|
||||||
|
expression="/manifest/@package" output="tested.manifest.package" />
|
||||||
|
|
||||||
|
<!-- TODO: make it more configurable in the next CL's - now it is default for auto-generated
|
||||||
|
project -->
|
||||||
|
<property name="emma.dump.file"
|
||||||
|
value="/data/data/${tested.manifest.package}/files/coverage.ec" />
|
||||||
|
|
||||||
|
<macrodef name="run-tests-helper">
|
||||||
|
<attribute name="emma.enabled" default="false" />
|
||||||
|
<element name="extra-instrument-args" optional="yes" />
|
||||||
|
<sequential>
|
||||||
|
<echo>Running tests ...</echo>
|
||||||
|
<exec executable="${adb}" failonerror="true">
|
||||||
|
<arg value="shell" />
|
||||||
|
<arg value="am" />
|
||||||
|
<arg value="instrument" />
|
||||||
|
<arg value="-w" />
|
||||||
|
<arg value="-e" />
|
||||||
|
<arg value="coverage" />
|
||||||
|
<arg value="@{emma.enabled}" />
|
||||||
|
<extra-instrument-args />
|
||||||
|
<arg value="${manifest.package}/${test.runner}" />
|
||||||
|
</exec>
|
||||||
|
</sequential>
|
||||||
|
</macrodef>
|
||||||
|
|
||||||
|
<!-- Invoking this target sets the value of extensible.classpath, which is being added to javac
|
||||||
|
classpath in target 'compile' (android_rules.xml) -->
|
||||||
|
<target name="-set-coverage-classpath">
|
||||||
|
<property name="extensible.classpath"
|
||||||
|
location="${instrumentation.absolute.dir}/classes" />
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- Ensures that tested project is installed on the device before we run the tests.
|
||||||
|
Used for ordinary tests, without coverage measurement -->
|
||||||
|
<target name="-install-tested-project">
|
||||||
|
<property name="do.not.compile.again" value="true" />
|
||||||
|
<subant target="install">
|
||||||
|
<fileset dir="${tested.project.absolute.dir}" includes="build.xml" />
|
||||||
|
</subant>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="run-tests" depends="-install-tested-project, install"
|
||||||
|
description="Runs tests from the package defined in test.package property">
|
||||||
|
<run-tests-helper />
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-install-instrumented">
|
||||||
|
<property name="do.not.compile.again" value="true" />
|
||||||
|
<subant target="-install-with-emma">
|
||||||
|
<property name="out.absolute.dir" value="${instrumentation.absolute.dir}" />
|
||||||
|
<fileset dir="${tested.project.absolute.dir}" includes="build.xml" />
|
||||||
|
</subant>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="coverage" depends="-set-coverage-classpath, -install-instrumented, install"
|
||||||
|
description="Runs the tests against the instrumented code and generates
|
||||||
|
code coverage report">
|
||||||
|
<run-tests-helper emma.enabled="true">
|
||||||
|
<extra-instrument-args>
|
||||||
|
<arg value="-e" />
|
||||||
|
<arg value="coverageFile" />
|
||||||
|
<arg value="${emma.dump.file}" />
|
||||||
|
</extra-instrument-args>
|
||||||
|
</run-tests-helper>
|
||||||
|
<echo>Downloading coverage file into project directory...</echo>
|
||||||
|
<exec executable="${adb}" failonerror="true">
|
||||||
|
<arg value="pull" />
|
||||||
|
<arg value="${emma.dump.file}" />
|
||||||
|
<arg value="coverage.ec" />
|
||||||
|
</exec>
|
||||||
|
<echo>Extracting coverage report...</echo>
|
||||||
|
<emma>
|
||||||
|
<report sourcepath="${tested.project.absolute.dir}/${source.dir}"
|
||||||
|
verbosity="${verbosity}">
|
||||||
|
<!-- TODO: report.dir or something like should be introduced if necessary -->
|
||||||
|
<infileset dir=".">
|
||||||
|
<include name="coverage.ec" />
|
||||||
|
<include name="coverage.em" />
|
||||||
|
</infileset>
|
||||||
|
<!-- TODO: reports in other, indicated by user formats -->
|
||||||
|
<html outfile="coverage.html" />
|
||||||
|
</report>
|
||||||
|
</emma>
|
||||||
|
<echo>Cleaning up temporary files...</echo>
|
||||||
|
<delete dir="${instrumentation.absolute.dir}" />
|
||||||
|
<delete file="coverage.ec" />
|
||||||
|
<delete file="coverage.em" />
|
||||||
|
<echo>Saving the report file in ${basedir}/coverage/coverage.html</echo>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -18,6 +18,6 @@ THIS FILE IS CURRENTLY BROKEN AND SHOULD NOT BE USED.
|
|||||||
<!-- Import the default Android build rules.
|
<!-- Import the default Android build rules.
|
||||||
This requires ant 1.6.0 or above. -->
|
This requires ant 1.6.0 or above. -->
|
||||||
|
|
||||||
<import file="${sdk-folder}/tools/lib/alias_rules.xml" />
|
<import file="${sdk.dir}/tools/lib/alias_rules.xml" />
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<project name="PROJECT_NAME" default="help">
|
<project name="PROJECT_NAME" default="help">
|
||||||
|
|
||||||
<!-- The local.properties file is created and updated by the 'android' tool.
|
<!-- The local.properties file is created and updated by the 'android' tool.
|
||||||
It contain the path to the SDK. It should *NOT* be checked in in Version
|
It contains the path to the SDK. It should *NOT* be checked in in Version
|
||||||
Control Systems. -->
|
Control Systems. -->
|
||||||
<property file="local.properties" />
|
<property file="local.properties" />
|
||||||
|
|
||||||
@@ -11,13 +11,13 @@
|
|||||||
used by the Ant rules.
|
used by the Ant rules.
|
||||||
Here are some properties you may want to change/update:
|
Here are some properties you may want to change/update:
|
||||||
|
|
||||||
application-package
|
application.package
|
||||||
the name of your application package as defined in the manifest. Used by the
|
the name of your application package as defined in the manifest. Used by the
|
||||||
'uninstall' rule.
|
'uninstall' rule.
|
||||||
source-folder
|
source.dir
|
||||||
the name of the source folder. Default is 'src'.
|
the name of the source directory. Default is 'src'.
|
||||||
out-folder
|
out.dir
|
||||||
the name of the output folder. 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
|
Properties related to the SDK location or the project target should be updated
|
||||||
using the 'android' tool with the 'update' action.
|
using the 'android' tool with the 'update' action.
|
||||||
@@ -37,11 +37,11 @@
|
|||||||
<!-- 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. -->
|
This requires ant 1.6.0 or above. -->
|
||||||
<path id="android.antlibs">
|
<path id="android.antlibs">
|
||||||
<pathelement path="${sdk-location}/tools/lib/anttasks.jar" />
|
<pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
|
||||||
<pathelement path="${sdk-location}/tools/lib/sdklib.jar" />
|
<pathelement path="${sdk.dir}/tools/lib/sdklib.jar" />
|
||||||
<pathelement path="${sdk-location}/tools/lib/androidprefs.jar" />
|
<pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" />
|
||||||
<pathelement path="${sdk-location}/tools/lib/apkbuilder.jar" />
|
<pathelement path="${sdk.dir}/tools/lib/apkbuilder.jar" />
|
||||||
<pathelement path="${sdk-location}/tools/lib/jarutils.jar" />
|
<pathelement path="${sdk.dir}/tools/lib/jarutils.jar" />
|
||||||
</path>
|
</path>
|
||||||
|
|
||||||
<taskdef name="setup"
|
<taskdef name="setup"
|
||||||
@@ -63,4 +63,5 @@
|
|||||||
build steps are used.
|
build steps are used.
|
||||||
-->
|
-->
|
||||||
<setup />
|
<setup />
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package PACKAGE;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
public class ACTIVITY_NAME extends Activity
|
public class ACTIVITY_CLASS_NAME extends Activity
|
||||||
{
|
{
|
||||||
/** Called when the activity is first created. */
|
/** Called when the activity is first created. */
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -9,13 +9,13 @@ import android.test.ActivityInstrumentationTestCase2;
|
|||||||
* <p/>
|
* <p/>
|
||||||
* To run this test, you can type:
|
* To run this test, you can type:
|
||||||
* adb shell am instrument -w \
|
* adb shell am instrument -w \
|
||||||
* -e class PACKAGE.ACTIVITY_NAMETest \
|
* -e class ACTIVITY_FQ_NAME \
|
||||||
* PACKAGE.tests/android.test.InstrumentationTestRunner
|
* PACKAGE.tests/android.test.InstrumentationTestRunner
|
||||||
*/
|
*/
|
||||||
public class ACTIVITY_NAMETest extends ActivityInstrumentationTestCase2<ACTIVITY_NAME> {
|
public class ACTIVITY_CLASS_NAME extends ActivityInstrumentationTestCase2<ACTIVITY_TESTED_CLASS_NAME> {
|
||||||
|
|
||||||
public ACTIVITY_NAMETest() {
|
public ACTIVITY_CLASS_NAME() {
|
||||||
super("PACKAGE", ACTIVITY_NAME.class);
|
super("PACKAGE", ACTIVITY_TESTED_CLASS_NAME.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user