diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/android_rules.xml | 227 | ||||
-rw-r--r-- | scripts/build.template | 61 | ||||
-rw-r--r-- | scripts/default.properties.template | 18 |
3 files changed, 138 insertions, 168 deletions
diff --git a/scripts/android_rules.xml b/scripts/android_rules.xml index bed5f24..1331696 100644 --- a/scripts/android_rules.xml +++ b/scripts/android_rules.xml @@ -1,112 +1,73 @@ <?xml version="1.0" ?> <project name="android_rules" default="debug"> - <!-- No user servicable parts below. --> - - <property name="outdir-main" value="../${outdir}" /> - - <property name="android-tools" value="${sdk-folder}/tools" /> - <property name="android-platform" value="${sdk-folder}/platforms/${target-folder}" /> - <property name="android-framework" value="${android-platform}/framework.aidl" /> - <property name="android-jar" value="${android-platform}/android.jar" /> + <property name="android-tools" value="${sdk-location}/tools" /> <!-- Input directories --> - <property name="resource-dir" value="res" /> - <property name="asset-dir" value="assets" /> - <property name="srcdir" value="src" /> - <condition property="srcdir-ospath" - value="${basedir}\${srcdir}" - else="${basedir}/${srcdir}" > - <os family="windows"/> - </condition> + <property name="source-folder" value="src" /> + <property name="resource-folder" value="res" /> + <property name="asset-folder" value="assets" /> + <property name="source-location" value="${basedir}/${source-folder}" /> + <available file="${basedir}/${asset-folder}" property="has.asset.folder"/> <!-- folder for the 3rd party java libraries --> <property name="external-libs" value="libs" /> - <condition property="external-libs-ospath" - value="${basedir}\${external-libs}" - else="${basedir}/${external-libs}" > - <os family="windows"/> - </condition> + <property name="external-libs-location" value="${basedir}/${external-libs}"/> <!-- folder for the native libraries --> <property name="native-libs" value="libs" /> - <condition property="native-libs-ospath" - value="${basedir}\${native-libs}" - else="${basedir}/${native-libs}" > - <os family="windows"/> - </condition> + <property name="native-libs-location" value="${basedir}/${native-libs}"/> <!-- Output directories --> - <property name="outdir-classes" value="${outdir}/classes" /> - <condition property="outdir-classes-ospath" - value="${basedir}\${outdir-classes}" - else="${basedir}/${outdir-classes}" > - <os family="windows"/> - </condition> - <condition property="outdir-main-classes" - value="${outdir-main}/classes"> - <available file="${outdir-main}/classes" - type="dir"/> - </condition> + <property name="out-folder" value="bin" /> + <property name="out-classes" value="${out-folder}/classes" /> + <property name="out-classes-location" value="${basedir}/${out-classes}"/> + <!-- 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"/> <!-- Create R.java in the source directory --> - <property name="outdir-r" value="src" /> + <property name="r-folder" value="${source-folder}" /> <!-- Intermediate files --> <property name="dex-file" value="classes.dex" /> - <property name="intermediate-dex" value="${outdir}/${dex-file}" /> - <condition property="intermediate-dex-ospath" + <property name="intermediate-dex" value="${out-folder}/${dex-file}" /> + <!-- 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 --> - <property name="resources-package" value="${outdir}/${ant.project.name}.ap_" /> - <condition property="resources-package-ospath" - value="${basedir}\${resources-package}" - else="${basedir}/${resources-package}" > - <os family="windows"/> - </condition> + <property name="resources-package" value="${out-folder}/${ant.project.name}.ap_"/> + <property name="resources-package-location" value="${basedir}/${resources-package}"/> - <property name="out-debug-package" value="${outdir}/${ant.project.name}-debug.apk" /> - <condition property="out-debug-package-ospath" - value="${basedir}\${out-debug-package}" - else="${basedir}/${out-debug-package}" > - <os family="windows"/> - </condition> + <property name="out-debug-package" value="${out-folder}/${ant.project.name}-debug.apk"/> + <property name="out-debug-package-location" value="${basedir}/${out-debug-package}"/> - <property name="out-unsigned-package" value="${outdir}/${ant.project.name}-unsigned.apk" /> - <condition property="out-unsigned-package-ospath" - value="${basedir}\${out-unsigned-package}" - else="${basedir}/${out-unsigned-package}" > - <os family="windows"/> - </condition> + <property name="out-unsigned-package" value="${out-folder}/${ant.project.name}-unsigned.apk"/> + <property name="out-unsigned-package-location" value="${basedir}/${out-unsigned-package}"/> <!-- Tools --> - <condition property="aapt" value="${android-tools}/aapt.exe" else="${android-tools}/aapt" > - <os family="windows"/> - </condition> - <condition property="aidl" value="${android-tools}/aidl.exe" else="${android-tools}/aidl" > - <os family="windows"/> - </condition> - <condition property="adb" value="${android-tools}/adb.exe" else="${android-tools}/adb" > - <os family="windows"/> - </condition> - <condition property="dx" value="${android-tools}/dx.bat" else="${android-tools}/dx" > - <os family="windows"/> - </condition> - <condition property="apk-builder" value="${android-tools}/apkbuilder.bat" else="${android-tools}/apkbuilder" > - <os family="windows"/> - </condition> + <condition property="exe" value="exe" else=""><os family="windows"/></condition> + <condition property="bat" value="bat" else=""><os family="windows"/></condition> - <!-- Rules --> + <property name="aapt" value="${android-tools}/aapt${exe}"/> + <property name="aidl" value="${android-tools}/aidl${exe}"/> + <property name="adb" value="${android-tools}/adb${exe}"/> + <property name="dx" value="${android-tools}/dx${bat}"/> + <property name="apk-builder" value="${android-tools}/apkbuilder${bat}"/> + + <!-- rules --> <!-- Create the output directories if they don't exist yet. --> <target name="dirs"> <echo>Creating output directories if needed...</echo> - <mkdir dir="${outdir}" /> - <mkdir dir="${outdir-classes}" /> + <mkdir dir="${out-folder}" /> + <mkdir dir="${out-classes}" /> </target> <!-- Generate the R.java file for this project's resources. --> @@ -116,13 +77,13 @@ <arg value="package" /> <arg value="-m" /> <arg value="-J" /> - <arg value="${outdir-r}" /> + <arg path="${r-folder}" /> <arg value="-M" /> - <arg value="AndroidManifest.xml" /> + <arg path="AndroidManifest.xml" /> <arg value="-S" /> - <arg value="${resource-dir}" /> + <arg path="${resource-folder}" /> <arg value="-I" /> - <arg value="${android-jar}" /> + <arg path="${android-jar}" /> </exec> </target> @@ -130,9 +91,9 @@ <target name="aidl" depends="dirs"> <echo>Compiling aidl files into Java classes...</echo> <apply executable="${aidl}" failonerror="true"> - <arg value="-p${android-framework}" /> - <arg value="-I${srcdir}" /> - <fileset dir="${srcdir}"> + <arg value="-p${android-aidl}" /> + <arg value="-I${source-folder}" /> + <fileset dir="${source-folder}"> <include name="**/*.aidl"/> </fileset> </apply> @@ -141,113 +102,102 @@ <!-- Compile this project's .java files into .class files. --> <target name="compile" depends="dirs, resource-src, aidl"> <javac encoding="ascii" target="1.5" debug="true" extdirs="" - srcdir="${srcdir}" - destdir="${outdir-classes}" + srcdir="${source-folder}" + destdir="${out-classes}" bootclasspath="${android-jar}"> <classpath> <fileset dir="${external-libs}" includes="*.jar"/> - <pathelement path="${outdir-main-classes}"/> + <pathelement path="${main-out-classes}"/> </classpath> </javac> </target> <!-- Convert this project's .class files into .dex files. --> <target name="dex" depends="compile"> - <echo>Converting compiled files and external libraries into ${outdir}/${dex-file}...</echo> + <echo>Converting compiled files and external libraries into ${out-folder}/${dex-file}...</echo> <apply executable="${dx}" failonerror="true" parallel="true"> <arg value="--dex" /> - <arg value="--output=${intermediate-dex-ospath}" /> - <arg path="${outdir-classes-ospath}" /> + <arg value="--output=${intermediate-dex-location}" /> + <arg path="${out-classes-location}" /> <fileset dir="${external-libs}" includes="*.jar"/> </apply> </target> <!-- Put the project's resources into the output package file. --> - <target name="package-res-and-assets"> + <target name="package-res-and-assets" if="has.asset.folder"> <echo>Packaging resources and assets...</echo> <exec executable="${aapt}" failonerror="true"> <arg value="package" /> <arg value="-f" /> <arg value="-M" /> - <arg value="AndroidManifest.xml" /> + <arg path="AndroidManifest.xml" /> <arg value="-S" /> - <arg value="${resource-dir}" /> + <arg path="${resource-folder}" /> <arg value="-A" /> - <arg value="${asset-dir}" /> + <arg path="${asset-folder}" /> <arg value="-I" /> - <arg value="${android-jar}" /> + <arg path="${android-jar}" /> <arg value="-F" /> <arg value="${resources-package}" /> </exec> </target> - <!-- Same as package-res-and-assets, but without "-A ${asset-dir}" --> - <target name="package-res-no-assets"> + <!-- Same as package-res-and-assets, but without "-A ${asset-folder}" --> + <target name="package-res-no-assets" unless="has.asset.folder"> <echo>Packaging resources...</echo> <exec executable="${aapt}" failonerror="true"> <arg value="package" /> <arg value="-f" /> <arg value="-M" /> - <arg value="AndroidManifest.xml" /> + <arg path="AndroidManifest.xml" /> <arg value="-S" /> - <arg value="${resource-dir}" /> + <arg path="${resource-folder}" /> <!-- No assets directory --> <arg value="-I" /> - <arg value="${android-jar}" /> + <arg path="${android-jar}" /> <arg value="-F" /> - <arg value="${resources-package}" /> + <arg path="${resources-package}" /> </exec> </target> - <!-- Invoke the proper target depending on whether or not - an assets directory is present. --> - <!-- TODO: find a nicer way to include the "-A ${asset-dir}" argument - only when the assets dir exists. --> - <target name="package-res"> - <available file="${asset-dir}" type="dir" - property="res-target" value="and-assets" /> - <property name="res-target" value="no-assets" /> - <antcall target="package-res-${res-target}" /> - </target> - <!-- Package the application and sign it with a debug key. This is the default target when building. It is used for debug. --> - <target name="debug" depends="dex, package-res"> + <target name="debug" depends="dex, package-res-and-assets, package-res-no-assets"> <echo>Packaging ${out-debug-package}, and signing it with a debug key...</echo> <exec executable="${apk-builder}" failonerror="true"> - <arg value="${out-debug-package-ospath}" /> + <arg value="${out-debug-package-location}" /> <arg value="-z" /> - <arg value="${resources-package-ospath}" /> + <arg path="${resources-package-location}" /> <arg value="-f" /> - <arg value="${intermediate-dex-ospath}" /> + <arg path="${intermediate-dex-location}" /> <arg value="-rf" /> - <arg value="${srcdir-ospath}" /> + <arg path="${source-location}" /> <arg value="-rj" /> - <arg value="${external-libs-ospath}" /> + <arg path="${external-libs-location}" /> <arg value="-nf" /> - <arg value="${native-libs-ospath}" /> + <arg path="${native-libs-location}" /> </exec> </target> <!-- Package the application without signing it. This allows for the application to be signed later with an official publishing key. --> - <target name="release" depends="dex, package-res"> + <target name="release" depends="dex, package-res-and-assets, package-res-no-assets"> <echo>Packaging ${out-unsigned-package} for release...</echo> <exec executable="${apk-builder}" failonerror="true"> - <arg value="${out-unsigned-package-ospath}" /> + <arg value="${out-unsigned-package-location}" /> <arg value="-u" /> <arg value="-z" /> - <arg value="${resources-package-ospath}" /> + <arg path="${resources-package-location}" /> <arg value="-f" /> - <arg value="${intermediate-dex-ospath}" /> + <arg path="${intermediate-dex-location}" /> <arg value="-rf" /> - <arg value="${srcdir-ospath}" /> + <arg path="${source-location}" /> <arg value="-rj" /> - <arg value="${external-libs-ospath}" /> + <arg path="${external-libs-location}" /> <arg value="-nf" /> - <arg value="${native-libs-ospath}" /> + <arg path="${native-libs-location}" /> </exec> - <echo>It will need to be signed with jarsigner before being published.</echo> + <echo>It will need to be signed with jarsigner before it is published.</echo> </target> <!-- Install the package on the default emulator --> @@ -255,7 +205,7 @@ <echo>Installing ${out-debug-package} onto default emulator...</echo> <exec executable="${adb}" failonerror="true"> <arg value="install" /> - <arg value="${out-debug-package}" /> + <arg path="${out-debug-package}" /> </exec> </target> @@ -264,7 +214,7 @@ <exec executable="${adb}" failonerror="true"> <arg value="install" /> <arg value="-r" /> - <arg value="${out-debug-package}" /> + <arg path="${out-debug-package}" /> </exec> </target> @@ -273,8 +223,25 @@ <echo>Uninstalling ${application-package} from the default emulator...</echo> <exec executable="${adb}" failonerror="true"> <arg value="uninstall" /> - <arg value="${application-package}" /> + <arg path="${application-package}" /> </exec> </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> debug: Builds the application and sign it with a debug key.</echo> + <echo> release: Builds the application. The generated apk file must be</echo> + <echo> signed before it is published.</echo> + <echo> install: Installs the debug package onto a running emulator or</echo> + <echo> device. This can only be used if the application has </echo> + <echo> not yet been installed.</echo> + <echo> reinstall: Installs the debug package on a running emulator or</echo> + <echo> device that already has the application.</echo> + <echo> The signatures must match.</echo> + <echo> uninstall: uninstall the application from a running emulator or</echo> + <echo> device.</echo> + </target> </project> diff --git a/scripts/build.template b/scripts/build.template index f04f1d8..c1afef8 100644 --- a/scripts/build.template +++ b/scripts/build.template @@ -1,30 +1,51 @@ <?xml version="1.0" ?> -<project name="ACTIVITY_NAME" default="debug"> +<project name="ACTIVITY_NAME" default="help"> + + <!-- 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 + Control Systems. --> + <property file="local.properties"/> <!-- The build.properties file can be created by you and is never touched - by activitycreator. If you want to manually set properties, this is - the best place to set them. --> - <property file="build.properties"/> + 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. + source-folder + the name of the source folder. Default is 'src'. + out-folder + the name of the output folder. Default is 'bin'. - <!-- The default.properties file is created and updated by activitycreator. - It will set any properties not already defined by build.properties. --> - <property file="default.properties"/> + Properties related to the SDK location or the project target should be updated + using the 'android' tool with the 'update' action. - <!-- ************************************************************************************* --> - <!-- These settings were written by activitycreator. - Do not change them unless you really know what you are doing. --> + This file is an integral part of the build system for your application and + should be checked in in Version Control Systems. - <!-- Application Package Name --> - <property name="application-package" value="PACKAGE" /> + --> + <property file="build.properties"/> - <!-- The intermediates directory, Eclipse uses "bin" - for its own output, so we do the same. --> - <property name="outdir" value="bin" /> - - <!-- ************************************************************************************* --> - <!-- Import the default Android build rules. - This requires ant 1.6.0 or above. --> + <!-- 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"/> - <import file="${sdk-folder}/tools/lib/android_rules.xml" /> + <!-- 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-location}/tools/lib/anttasks.jar" /> + <pathelement path="${sdk-location}/tools/lib/sdklib.jar" /> + <pathelement path="${sdk-location}/tools/lib/androidprefs.jar" /> + </path> + + <taskdef name="androidinit" classname="com.android.ant.AndroidInitTask" + classpathref="android.antlibs"/> + <!-- Class the Android Init task that will import the proper rule file containing + all the Ant targets --> + <androidinit /> </project> diff --git a/scripts/default.properties.template b/scripts/default.properties.template deleted file mode 100644 index 63df494..0000000 --- a/scripts/default.properties.template +++ /dev/null @@ -1,18 +0,0 @@ -# This file is automatically generated by activitycreator. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# Instead customize values in a "build.properties" file. - -# location of the SDK -sdk-folder=ANDROID_SDK_FOLDER - -# target mode. Value can be "platform" or "add-on" -target-mode=TARGET_MODE - -# target API level. -target-api=TARGET_API - -# target name, if target-mode=add-on -target-name=TARGET_NAME - -# target platform. This is either the target itself or the platform the add-on is based on. -target-folder=TARGET_FOLDER |