Christian Williams & Ian Fisher | 780ae89 | 2010-08-09 17:35:10 -0700 | [diff] [blame] | 1 | <?xml version="1.0" encoding="UTF-8"?> |
Christian Williams & Ryan Richard | 5749405 | 2010-09-30 12:21:06 -0700 | [diff] [blame] | 2 | <project name="robolectric" default="test"> |
Christian Williams & Ian Fisher | 780ae89 | 2010-08-09 17:35:10 -0700 | [diff] [blame] | 3 | |
| 4 | <!-- The build.properties file can be created by you and is never touched |
| 5 | by the 'android' tool. This is the place to change some of the default property values |
| 6 | used by the Ant rules. |
| 7 | Here are some properties you may want to change/update: |
| 8 | |
| 9 | application.package |
| 10 | the name of your application package as defined in the manifest. Used by the |
| 11 | 'uninstall' rule. |
| 12 | source.dir |
| 13 | the name of the source directory. Default is 'src'. |
| 14 | out.dir |
| 15 | the name of the output directory. Default is 'bin'. |
| 16 | |
| 17 | Properties related to the SDK location or the project target should be updated |
| 18 | using the 'android' tool with the 'update' action. |
| 19 | |
| 20 | This file is an integral part of the build system for your application and |
| 21 | should be checked in in Version Control Systems. |
| 22 | |
| 23 | --> |
| 24 | <property file="build.properties"/> |
| 25 | |
| 26 | <!-- The default.properties file is created and updated by the 'android' tool, as well |
| 27 | as ADT. |
| 28 | This file is an integral part of the build system for your application and |
| 29 | should be checked in in Version Control Systems. --> |
| 30 | <property file="default.properties"/> |
| 31 | |
Jesse Toth & Tim Labeeuw | d2edc26 | 2011-08-09 11:16:10 -0700 | [diff] [blame] | 32 | <condition property="isWindows"> <os family="windows" /> </condition> |
| 33 | |
| 34 | <target name="findAndroidWindows" if="isWindows"> |
| 35 | <echo message="Finding the Android version in windows"/> |
| 36 | <exec executable="./find-android.bat"/> |
| 37 | </target> |
| 38 | <target name="findAndroidUnix" unless="isWindows"> |
| 39 | <echo message="Finding the Android version in *nix"/> |
| 40 | <exec executable="./find-android.sh"/> |
| 41 | </target> |
Phil Goodwin | 6a85565 | 2011-01-18 12:21:13 -0800 | [diff] [blame] | 42 | <property file="local.properties"/> |
Christian Williams & Ian Fisher | 780ae89 | 2010-08-09 17:35:10 -0700 | [diff] [blame] | 43 | |
| 44 | <!-- Custom Android task to deal with the project target, and import the proper rules. |
| 45 | This requires ant 1.6.0 or above. --> |
| 46 | <path id="android.antlibs"> |
| 47 | <pathelement path="${sdk.dir}/tools/lib/anttasks.jar"/> |
| 48 | <pathelement path="${sdk.dir}/tools/lib/sdklib.jar"/> |
| 49 | <pathelement path="${sdk.dir}/tools/lib/androidprefs.jar"/> |
| 50 | <pathelement path="${sdk.dir}/tools/lib/apkbuilder.jar"/> |
| 51 | <pathelement path="${sdk.dir}/tools/lib/jarutils.jar"/> |
| 52 | </path> |
| 53 | |
| 54 | <path id="android.target.classpath"> |
Michael Portuesi | f99fa78 | 2012-09-12 15:58:52 -0700 | [diff] [blame] | 55 | <pathelement path="${sdk.dir}/platforms/android-16/android.jar"/> |
| 56 | <pathelement path="${sdk.dir}/add-ons/addon_google_apis_google_inc_16/libs/maps.jar"/> |
| 57 | <pathelement path="${sdk.dir}/add-ons/addon-google_apis-google_inc_-16/libs/maps.jar"/> |
| 58 | <pathelement path="${sdk.dir}/add-ons/addon-google_apis-google-16/libs/maps.jar"/> |
Aaron VonderHaar & Amrit Thakur | d1a3090 | 2012-03-19 10:38:52 -0700 | [diff] [blame] | 59 | <pathelement path="${sdk.dir}/extras/android/support/v4/android-support-v4.jar"/> |
Rich Humphrey | 704006c | 2012-05-01 20:45:03 -0700 | [diff] [blame] | 60 | <pathelement path="${sdk.dir}/android-compatibility/v4/android-support-v4.jar"/> |
Christian Williams & Ian Fisher | 780ae89 | 2010-08-09 17:35:10 -0700 | [diff] [blame] | 61 | </path> |
| 62 | |
| 63 | <property name="main.absolute.dir" location="${main.dir}"/> |
| 64 | <property name="out.main.dir" value="${out.absolute.dir}/mainClasses"/> |
| 65 | <property name="out.main.absolute.dir" value="${out.main.dir}"/> |
| 66 | <property name="main.external.libs.dir" value="lib/main"/> |
| 67 | <property name="main.external.libs.absolute.dir" location="${main.external.libs.dir}"/> |
| 68 | |
| 69 | <property name="test.absolute.dir" location="${test.dir}"/> |
| 70 | <property name="out.test.dir" value="${out.absolute.dir}/testClasses"/> |
| 71 | <property name="out.test.absolute.dir" value="${out.test.dir}"/> |
Christian Williams | 661c3bf | 2010-10-26 16:22:17 -0700 | [diff] [blame] | 72 | <property name="test.external.libs.dir" value="lib/test"/> |
| 73 | <property name="test.external.libs.absolute.dir" location="${test.external.libs.dir}"/> |
| 74 | |
Christian Williams & Ian Fisher | 780ae89 | 2010-08-09 17:35:10 -0700 | [diff] [blame] | 75 | <property name="publish.dir" location="${out.absolute.dir}/publish"/> |
| 76 | |
Phil Goodwin | e35eaaf | 2010-11-18 15:49:39 -0800 | [diff] [blame] | 77 | <property name="pages.dir" value="pages"/> |
| 78 | <property name="downloads.dir" value="${pages.dir}/downloads"/> |
| 79 | <property name="javadoc.out.dir" value="${pages.dir}/javadoc"/> |
| 80 | |
| 81 | <property name="base.package" value="com.xtremelabs.robolectric"/> |
| 82 | |
Christian Williams & Ian Fisher | 780ae89 | 2010-08-09 17:35:10 -0700 | [diff] [blame] | 83 | <property environment="env"/> |
| 84 | <condition property="build.number" value="${env.BUILD_NUMBER}" else="unknown"> |
| 85 | <isset property="env.BUILD_NUMBER"/> |
| 86 | </condition> |
| 87 | |
| 88 | <target name="compile" |
Jesse Toth & Tim Labeeuw | d2edc26 | 2011-08-09 11:16:10 -0700 | [diff] [blame] | 89 | description="compile module source" |
| 90 | depends="findAndroidUnix, findAndroidWindows"> |
Christian Williams & Ian Fisher | 780ae89 | 2010-08-09 17:35:10 -0700 | [diff] [blame] | 91 | <mkdir dir="${out.main.absolute.dir}"/> |
| 92 | |
| 93 | <javac encoding="ascii" source="1.6" target="1.6" debug="true" extdirs="" |
| 94 | destdir="${out.main.absolute.dir}" |
Phil Goodwin & Tyler Schultz | 5010e89 | 2010-11-24 12:14:01 -0800 | [diff] [blame] | 95 | verbose="${verbose}" |
| 96 | classpath="${extensible.classpath}" |
| 97 | includeantruntime="false"> |
Christian Williams & Ian Fisher | 780ae89 | 2010-08-09 17:35:10 -0700 | [diff] [blame] | 98 | <src path="${main.absolute.dir}"/> |
| 99 | <classpath> |
| 100 | <pathelement path="${out.main.absolute.dir}"/> |
| 101 | <path refid="android.target.classpath"/> |
| 102 | <fileset dir="${main.external.libs.absolute.dir}" includes="*.jar"/> |
| 103 | </classpath> |
| 104 | </javac> |
| 105 | </target> |
| 106 | |
Christian Williams & Phil Goodwin | 986790e | 2010-11-02 16:46:59 -0700 | [diff] [blame] | 107 | <target name="jar" description="create the robolectric jar" depends="compile"> |
Christian Williams & Phil Goodwin | 8f62a59 | 2010-11-02 11:41:26 -0700 | [diff] [blame] | 108 | <mkdir dir="${target.dir}"/> |
Christian Williams & Phil Goodwin | 0e7edc4 | 2010-11-03 10:21:54 -0700 | [diff] [blame] | 109 | <jar destfile="${target.dir}/robolectric.jar"> |
| 110 | <fileset dir="${out.main.absolute.dir}" includes="**/*.class"/> |
| 111 | </jar> |
Phil Goodwin | d6d683b | 2010-11-02 09:39:00 -0700 | [diff] [blame] | 112 | </target> |
| 113 | |
Christian Williams & Phil Goodwin | 0e7edc4 | 2010-11-03 10:21:54 -0700 | [diff] [blame] | 114 | <target name="jar-all" description="create the robolectric jar including all dependencies" depends="jar"> |
Christian Williams & Phil Goodwin | 986790e | 2010-11-02 16:46:59 -0700 | [diff] [blame] | 115 | <mkdir dir="${target.dir}/staging"/> |
Phil Goodwin & Tyler Schultz | 470a83d | 2010-12-14 10:47:17 -0800 | [diff] [blame] | 116 | <unjar dest="${target.dir}/staging" > |
| 117 | <fileset dir="${main.external.libs.absolute.dir}" > |
| 118 | <exclude name="*src.jar" /> |
| 119 | <exclude name="junit*.jar" /> |
Phil Goodwin & Tyler Schultz | a900bb7 | 2010-12-15 15:33:56 -0800 | [diff] [blame] | 120 | <exclude name="hamcrest*.jar" /> |
Phil Goodwin & Tyler Schultz | 470a83d | 2010-12-14 10:47:17 -0800 | [diff] [blame] | 121 | </fileset> |
| 122 | </unjar> |
Christian Williams & Phil Goodwin | 986790e | 2010-11-02 16:46:59 -0700 | [diff] [blame] | 123 | <unjar dest="${target.dir}/staging" src="${target.dir}/robolectric.jar"/> |
| 124 | <jar destfile="${target.dir}/robolectric-all.jar" basedir="${target.dir}/staging"/> |
| 125 | <delete dir="${target.dir}/staging"/> |
| 126 | </target> |
| 127 | |
Christian Williams, Phil Goodwin & Tyler Schultz | 3ad8c94 | 2010-11-17 17:03:53 -0800 | [diff] [blame] | 128 | <target name="source-jar" description="create a jar file that includes all of the source code"> |
| 129 | <mkdir dir="${target.dir}"/> |
| 130 | <jar destfile="${target.dir}/robolectric-src.jar" basedir="${main.absolute.dir}"/> |
| 131 | </target> |
| 132 | |
Christian Williams & Ian Fisher | 780ae89 | 2010-08-09 17:35:10 -0700 | [diff] [blame] | 133 | <target name="compile.tests" depends="compile" |
Phil Goodwin | e35eaaf | 2010-11-18 15:49:39 -0800 | [diff] [blame] | 134 | description="compile module source; test classes" unless="skip.tests"> |
Christian Williams & Ian Fisher | 780ae89 | 2010-08-09 17:35:10 -0700 | [diff] [blame] | 135 | <mkdir dir="${out.test.absolute.dir}"/> |
| 136 | |
| 137 | <javac encoding="ascii" source="1.6" target="1.6" debug="true" extdirs="" |
Phil Goodwin | e35eaaf | 2010-11-18 15:49:39 -0800 | [diff] [blame] | 138 | destdir="${out.test.absolute.dir}" |
Phil Goodwin & Tyler Schultz | 5010e89 | 2010-11-24 12:14:01 -0800 | [diff] [blame] | 139 | verbose="${verbose}" |
| 140 | classpath="${extensible.classpath}" |
| 141 | includeantruntime="false"> |
Christian Williams & Ian Fisher | 780ae89 | 2010-08-09 17:35:10 -0700 | [diff] [blame] | 142 | <src path="${test.absolute.dir}"/> |
| 143 | <classpath> |
| 144 | <pathelement path="${out.main.absolute.dir}"/> |
| 145 | <pathelement path="${out.test.absolute.dir}"/> |
| 146 | <path refid="android.target.classpath"/> |
| 147 | <fileset dir="${main.external.libs.absolute.dir}" includes="*.jar"/> |
Christian Williams | 661c3bf | 2010-10-26 16:22:17 -0700 | [diff] [blame] | 148 | <fileset dir="${test.external.libs.absolute.dir}" includes="*.jar"/> |
Christian Williams & Ian Fisher | 780ae89 | 2010-08-09 17:35:10 -0700 | [diff] [blame] | 149 | </classpath> |
| 150 | </javac> |
| 151 | </target> |
| 152 | |
| 153 | <target name="clean" description="cleanup module"> |
| 154 | <delete dir="${out.absolute.dir}"/> |
| 155 | <delete dir="${out.test.absolute.dir}"/> |
Joe Moore & Phil Goodwin | 56c1c7d | 2010-10-27 10:01:00 -0700 | [diff] [blame] | 156 | <delete dir="${tmp.dir}"/> |
Phil Goodwin & Tyler Schultz | 470a83d | 2010-12-14 10:47:17 -0800 | [diff] [blame] | 157 | <delete dir="${target.dir}"/> |
Christian Williams & Ian Fisher | 780ae89 | 2010-08-09 17:35:10 -0700 | [diff] [blame] | 158 | </target> |
| 159 | |
| 160 | <target name="test" depends="compile.tests" description="test all"> |
| 161 | <mkdir dir="${basedir}/out/reports/tests"/> |
Tyler Schultz | e8502e0 | 2010-10-22 14:45:34 -0700 | [diff] [blame] | 162 | <junit showoutput="true" failureproperty="junit.failure"> |
Phil Goodwin & Tyler Schultz | ddb525f | 2010-11-24 17:16:17 -0800 | [diff] [blame] | 163 | <formatter type="plain" usefile="false" if="junit.console.out"/> |
Christian Williams & Ian Fisher | 780ae89 | 2010-08-09 17:35:10 -0700 | [diff] [blame] | 164 | <formatter type="plain"/> |
| 165 | <formatter type="xml"/> |
| 166 | <batchtest todir="${basedir}/out/reports/tests"> |
Christian Williams | cd21db2 | 2010-12-22 14:09:31 -0800 | [diff] [blame] | 167 | <fileset dir="${test.absolute.dir}"> |
Christian Williams & Ian Fisher | 780ae89 | 2010-08-09 17:35:10 -0700 | [diff] [blame] | 168 | <include name="**/*Test.java"/> |
| 169 | </fileset> |
| 170 | </batchtest> |
| 171 | <classpath> |
| 172 | <pathelement path="${out.main.absolute.dir}"/> |
| 173 | <pathelement path="${out.test.absolute.dir}"/> |
| 174 | <fileset dir="${main.external.libs.dir}" includes="*.jar"/> |
Christian Williams | 661c3bf | 2010-10-26 16:22:17 -0700 | [diff] [blame] | 175 | <fileset dir="${test.external.libs.dir}" includes="*.jar"/> |
Christian Williams & Ian Fisher | 780ae89 | 2010-08-09 17:35:10 -0700 | [diff] [blame] | 176 | <path refid="android.target.classpath"/> |
| 177 | </classpath> |
| 178 | </junit> |
Tyler Schultz | e8502e0 | 2010-10-22 14:45:34 -0700 | [diff] [blame] | 179 | <fail if="junit.failure" message="Unit test(s) failed. See reports!"/> |
Christian Williams & Ian Fisher | 780ae89 | 2010-08-09 17:35:10 -0700 | [diff] [blame] | 180 | </target> |
| 181 | |
Phil Goodwin | e35eaaf | 2010-11-18 15:49:39 -0800 | [diff] [blame] | 182 | <target name="check-for-pages-dir-setup"> |
| 183 | <condition property="pages.dir.exists"> |
| 184 | <available file="${pages.dir}" type="dir"/> |
| 185 | </condition> |
| 186 | </target> |
| 187 | |
| 188 | <target name="check-for-pages-dir" depends="check-for-pages-dir-setup" unless="pages.dir.exists"> |
| 189 | <echo message="do you need a 'pages' symlink?"/> |
| 190 | </target> |
| 191 | |
Phil Goodwin & Tyler Schultz | 8808add | 2010-12-13 14:26:52 -0800 | [diff] [blame] | 192 | <target name="snapshot" description="update most recent version of robolectric as jars" depends="clean, test, jar-all, source-jar, check-for-pages-dir" if="pages.dir.exists"> |
Phil Goodwin | e35eaaf | 2010-11-18 15:49:39 -0800 | [diff] [blame] | 193 | <copy todir="${downloads.dir}"> |
| 194 | <fileset dir="${target.dir}" includes="robolectric*.jar"/> |
| 195 | </copy> |
| 196 | <exec executable="./update-downloads.rb"/> |
| 197 | </target> |
| 198 | |
| 199 | <target name="gen-javadoc" description="generate javadoc for the public API" depends="check-for-pages-dir" if="pages.dir.exists"> |
| 200 | <mkdir dir="${javadoc.out.dir}" /> |
| 201 | <javadoc |
Christian Williams | cd21db2 | 2010-12-22 14:09:31 -0800 | [diff] [blame] | 202 | packagenames="${base.package}.*" |
| 203 | access="protected" |
Phil Goodwin | e35eaaf | 2010-11-18 15:49:39 -0800 | [diff] [blame] | 204 | defaultexcludes="yes" |
| 205 | windowtitle="Robolectric API" |
| 206 | sourcepath="${main.absolute.dir}" |
| 207 | overview="${main.absolute.dir}/overview.html" |
| 208 | destdir="${javadoc.out.dir}"> |
| 209 | <classpath> |
| 210 | <pathelement path="${out.main.absolute.dir}"/> |
| 211 | <path refid="android.target.classpath"/> |
| 212 | <fileset dir="${main.external.libs.absolute.dir}" includes="*.jar"/> |
| 213 | </classpath> |
| 214 | <doctitle><![CDATA[<h1>Robolectric<br/>API Documentation</h1>]]></doctitle> |
| 215 | </javadoc> |
| 216 | </target> |
Phil Goodwin | 58f7b6e | 2011-01-26 14:07:47 -0800 | [diff] [blame] | 217 | |
| 218 | <target name="maven-install-jars" description="Install the jar files that Maven can't find for itself"> |
| 219 | <exec executable="mvn"> |
Ian Fisher & Tyler Schultz | a739b57 | 2011-07-07 13:14:08 -0700 | [diff] [blame] | 220 | <arg line="install:install-file -DgroupId=com.google.android.maps -DartifactId=maps -Dversion=10_r2 -Dpackaging=jar -Dfile=${sdk.dir}/add-ons/addon_google_apis_google_inc_10/libs/maps.jar" /> |
Phil Goodwin | 58f7b6e | 2011-01-26 14:07:47 -0800 | [diff] [blame] | 221 | </exec> |
Phil Goodwin | 6301612 | 2012-01-19 17:14:47 -0800 | [diff] [blame] | 222 | <exec executable="mvn"> |
| 223 | <arg line="install:install-file -DgroupId=com.google.android.maps -DartifactId=maps -Dversion=10_r2 -Dpackaging=jar -Dfile=${sdk.dir}/add-ons/addon-google_apis-google_inc_-10/libs/maps.jar" /> |
| 224 | </exec> |
Phil Goodwin & Rick Kawala | f9d5ac6 | 2012-07-24 16:09:31 -0700 | [diff] [blame] | 225 | <exec executable="mvn"> |
| 226 | <arg line="install:install-file -DgroupId=com.google.android.maps -DartifactId=maps -Dversion=10_r2 -Dpackaging=jar -Dfile=${sdk.dir}/add-ons/addon-google_apis-google-10/libs/maps.jar" /> |
| 227 | </exec> |
Phil Goodwin | 58f7b6e | 2011-01-26 14:07:47 -0800 | [diff] [blame] | 228 | </target> |
Jan Berkel | e3f7461 | 2012-05-08 18:12:29 +0200 | [diff] [blame] | 229 | |
| 230 | <!-- used by travis-ci --> |
| 231 | <target name="prepare-travis-ci" description="Prepare for travis ci build"> |
| 232 | <mkdir dir="tmp"/> |
Jan Berkel | 0d4fc51 | 2012-08-21 12:39:14 +0200 | [diff] [blame] | 233 | <get src="http://dl.google.com/android/android-sdk_r20.0.3-linux.tgz" dest="tmp" skipexisting="true"/> |
| 234 | <untar src="tmp/android-sdk_r20.0.3-linux.tgz" compression="gzip" dest="tmp/sdk"/> |
Jan Berkel | e3f7461 | 2012-05-08 18:12:29 +0200 | [diff] [blame] | 235 | <echo file="tmp/install-sdk">#!/bin/sh -e |
| 236 | ANDROID="tmp/sdk/android-sdk-linux/tools/android" |
| 237 | chmod +x $ANDROID |
Jan Berkel | 0d4fc51 | 2012-08-21 12:39:14 +0200 | [diff] [blame] | 238 | SDKS=$($ANDROID list sdk --all | awk \ |
Jan Berkel | e3f7461 | 2012-05-08 18:12:29 +0200 | [diff] [blame] | 239 | '/SDK Platform.* API 10/ || /Google APIs, Android API 10, revision 2/ \ |
| 240 | { s=s "," int($1) } \ |
| 241 | END { print substr(s, 2, length(s)) }' \ |
| 242 | ) |
Jan Berkel | 0d4fc51 | 2012-08-21 12:39:14 +0200 | [diff] [blame] | 243 | $ANDROID update sdk --no-ui --all --filter $SDKS |
Jan Berkel | e3f7461 | 2012-05-08 18:12:29 +0200 | [diff] [blame] | 244 | </echo> |
| 245 | <chmod file="tmp/install-sdk" perm="u+x"/> |
| 246 | <exec executable="tmp/install-sdk"/> |
| 247 | <propertyfile file="local.properties"> |
| 248 | <entry key="sdk.dir" value="${basedir}/tmp/sdk/android-sdk-linux/"/> |
| 249 | </propertyfile> |
| 250 | <exec executable="mvn"> |
| 251 | <arg line="install:install-file -DgroupId=com.google.android.maps -DartifactId=maps -Dversion=10_r2 -Dpackaging=jar -Dfile=tmp/sdk/android-sdk-linux/add-ons/addon-google_apis-google-10/libs/maps.jar"/> |
| 252 | </exec> |
| 253 | </target> |
Christian Williams & Ian Fisher | 780ae89 | 2010-08-09 17:35:10 -0700 | [diff] [blame] | 254 | </project> |