blob: e183a482b6dd6104a5e9c2e56f6ee57179bfd11f [file] [log] [blame]
Christian Williams & Ian Fisher780ae892010-08-09 17:35:10 -07001<?xml version="1.0" encoding="UTF-8"?>
Christian Williams & Ryan Richard57494052010-09-30 12:21:06 -07002<project name="robolectric" default="test">
Christian Williams & Ian Fisher780ae892010-08-09 17:35:10 -07003
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 Labeeuwd2edc262011-08-09 11:16:10 -070032 <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 Goodwin6a855652011-01-18 12:21:13 -080042 <property file="local.properties"/>
Christian Williams & Ian Fisher780ae892010-08-09 17:35:10 -070043
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 Portuesif99fa782012-09-12 15:58:52 -070055 <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 Thakurd1a30902012-03-19 10:38:52 -070059 <pathelement path="${sdk.dir}/extras/android/support/v4/android-support-v4.jar"/>
Rich Humphrey704006c2012-05-01 20:45:03 -070060 <pathelement path="${sdk.dir}/android-compatibility/v4/android-support-v4.jar"/>
Christian Williams & Ian Fisher780ae892010-08-09 17:35:10 -070061 </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 Williams661c3bf2010-10-26 16:22:17 -070072 <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 Fisher780ae892010-08-09 17:35:10 -070075 <property name="publish.dir" location="${out.absolute.dir}/publish"/>
76
Phil Goodwine35eaaf2010-11-18 15:49:39 -080077 <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 Fisher780ae892010-08-09 17:35:10 -070083 <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 Labeeuwd2edc262011-08-09 11:16:10 -070089 description="compile module source"
90 depends="findAndroidUnix, findAndroidWindows">
Christian Williams & Ian Fisher780ae892010-08-09 17:35:10 -070091 <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 Schultz5010e892010-11-24 12:14:01 -080095 verbose="${verbose}"
96 classpath="${extensible.classpath}"
97 includeantruntime="false">
Christian Williams & Ian Fisher780ae892010-08-09 17:35:10 -070098 <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 Goodwin986790e2010-11-02 16:46:59 -0700107 <target name="jar" description="create the robolectric jar" depends="compile">
Christian Williams & Phil Goodwin8f62a592010-11-02 11:41:26 -0700108 <mkdir dir="${target.dir}"/>
Christian Williams & Phil Goodwin0e7edc42010-11-03 10:21:54 -0700109 <jar destfile="${target.dir}/robolectric.jar">
110 <fileset dir="${out.main.absolute.dir}" includes="**/*.class"/>
111 </jar>
Phil Goodwind6d683b2010-11-02 09:39:00 -0700112 </target>
113
Christian Williams & Phil Goodwin0e7edc42010-11-03 10:21:54 -0700114 <target name="jar-all" description="create the robolectric jar including all dependencies" depends="jar">
Christian Williams & Phil Goodwin986790e2010-11-02 16:46:59 -0700115 <mkdir dir="${target.dir}/staging"/>
Phil Goodwin & Tyler Schultz470a83d2010-12-14 10:47:17 -0800116 <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 Schultza900bb72010-12-15 15:33:56 -0800120 <exclude name="hamcrest*.jar" />
Phil Goodwin & Tyler Schultz470a83d2010-12-14 10:47:17 -0800121 </fileset>
122 </unjar>
Christian Williams & Phil Goodwin986790e2010-11-02 16:46:59 -0700123 <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 Schultz3ad8c942010-11-17 17:03:53 -0800128 <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 Fisher780ae892010-08-09 17:35:10 -0700133 <target name="compile.tests" depends="compile"
Phil Goodwine35eaaf2010-11-18 15:49:39 -0800134 description="compile module source; test classes" unless="skip.tests">
Christian Williams & Ian Fisher780ae892010-08-09 17:35:10 -0700135 <mkdir dir="${out.test.absolute.dir}"/>
136
137 <javac encoding="ascii" source="1.6" target="1.6" debug="true" extdirs=""
Phil Goodwine35eaaf2010-11-18 15:49:39 -0800138 destdir="${out.test.absolute.dir}"
Phil Goodwin & Tyler Schultz5010e892010-11-24 12:14:01 -0800139 verbose="${verbose}"
140 classpath="${extensible.classpath}"
141 includeantruntime="false">
Christian Williams & Ian Fisher780ae892010-08-09 17:35:10 -0700142 <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 Williams661c3bf2010-10-26 16:22:17 -0700148 <fileset dir="${test.external.libs.absolute.dir}" includes="*.jar"/>
Christian Williams & Ian Fisher780ae892010-08-09 17:35:10 -0700149 </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 Goodwin56c1c7d2010-10-27 10:01:00 -0700156 <delete dir="${tmp.dir}"/>
Phil Goodwin & Tyler Schultz470a83d2010-12-14 10:47:17 -0800157 <delete dir="${target.dir}"/>
Christian Williams & Ian Fisher780ae892010-08-09 17:35:10 -0700158 </target>
159
160 <target name="test" depends="compile.tests" description="test all">
161 <mkdir dir="${basedir}/out/reports/tests"/>
Tyler Schultze8502e02010-10-22 14:45:34 -0700162 <junit showoutput="true" failureproperty="junit.failure">
Phil Goodwin & Tyler Schultzddb525f2010-11-24 17:16:17 -0800163 <formatter type="plain" usefile="false" if="junit.console.out"/>
Christian Williams & Ian Fisher780ae892010-08-09 17:35:10 -0700164 <formatter type="plain"/>
165 <formatter type="xml"/>
166 <batchtest todir="${basedir}/out/reports/tests">
Christian Williamscd21db22010-12-22 14:09:31 -0800167 <fileset dir="${test.absolute.dir}">
Christian Williams & Ian Fisher780ae892010-08-09 17:35:10 -0700168 <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 Williams661c3bf2010-10-26 16:22:17 -0700175 <fileset dir="${test.external.libs.dir}" includes="*.jar"/>
Christian Williams & Ian Fisher780ae892010-08-09 17:35:10 -0700176 <path refid="android.target.classpath"/>
177 </classpath>
178 </junit>
Tyler Schultze8502e02010-10-22 14:45:34 -0700179 <fail if="junit.failure" message="Unit test(s) failed. See reports!"/>
Christian Williams & Ian Fisher780ae892010-08-09 17:35:10 -0700180 </target>
181
Phil Goodwine35eaaf2010-11-18 15:49:39 -0800182 <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 Schultz8808add2010-12-13 14:26:52 -0800192 <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 Goodwine35eaaf2010-11-18 15:49:39 -0800193 <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 Williamscd21db22010-12-22 14:09:31 -0800202 packagenames="${base.package}.*"
203 access="protected"
Phil Goodwine35eaaf2010-11-18 15:49:39 -0800204 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 Goodwin58f7b6e2011-01-26 14:07:47 -0800217
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 Schultza739b572011-07-07 13:14:08 -0700220 <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 Goodwin58f7b6e2011-01-26 14:07:47 -0800221 </exec>
Phil Goodwin63016122012-01-19 17:14:47 -0800222 <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 Kawalaf9d5ac62012-07-24 16:09:31 -0700225 <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 Goodwin58f7b6e2011-01-26 14:07:47 -0800228 </target>
Jan Berkele3f74612012-05-08 18:12:29 +0200229
230 <!-- used by travis-ci -->
231 <target name="prepare-travis-ci" description="Prepare for travis ci build">
232 <mkdir dir="tmp"/>
Jan Berkel0d4fc512012-08-21 12:39:14 +0200233 <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 Berkele3f74612012-05-08 18:12:29 +0200235 <echo file="tmp/install-sdk">#!/bin/sh -e
236 ANDROID="tmp/sdk/android-sdk-linux/tools/android"
237 chmod +x $ANDROID
Jan Berkel0d4fc512012-08-21 12:39:14 +0200238 SDKS=$($ANDROID list sdk --all | awk \
Jan Berkele3f74612012-05-08 18:12:29 +0200239 '/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 Berkel0d4fc512012-08-21 12:39:14 +0200243 $ANDROID update sdk --no-ui --all --filter $SDKS
Jan Berkele3f74612012-05-08 18:12:29 +0200244 </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 Fisher780ae892010-08-09 17:35:10 -0700254</project>