• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<?xml version="1.0" ?>
2
3<project name="libphonenumber" default="compile">
4  <property name="libphonenumber.src.dir" value="libphonenumber/src"/>
5  <property name="libphonenumber.test.dir" value="libphonenumber/test"/>
6  <property name="carrier.src.dir" value="carrier/src"/>
7  <property name="carrier.test.dir" value="carrier/test"/>
8  <property name="geocoder.src.dir" value="geocoder/src"/>
9  <property name="geocoder.test.dir" value="geocoder/test"/>
10  <property name="prefixmapper.src.dir" value="internal/prefixmapper/src"/>
11  <property name="prefixmapper.test.dir" value="internal/prefixmapper/test"/>
12  <property name="build.dir" value="build"/>
13  <property name="classes.dir" value="${build.dir}/classes"/>
14  <property name="jar.dir" value="${build.dir}/jar"/>
15  <property name="lib.dir" value="lib"/>
16  <property name="report.dir" value="${build.dir}/junitreport"/>
17  <property name="resources.dir" value="../resources"/>
18  <property name="javascript.dir" value="../javascript"/>
19  <property name="build.tools.jar"
20      value="../tools/java/java-build/target/java-build-1.0-SNAPSHOT-jar-with-dependencies.jar"/>
21
22  <path id="classpath">
23    <fileset dir="${lib.dir}" includes="**/*.jar"/>
24  </path>
25  <path id="test.classpath">
26    <pathelement location="${classes.dir}"/>
27    <pathelement location="${lib.dir}/junit/junit-4.8.1.jar"/>
28    <pathelement location="${jar.dir}/${ant.project.name}-test.jar"/>
29    <fileset dir="${lib.dir}">
30      <include name="**/*.jar"/>
31    </fileset>
32  </path>
33
34  <target name="build-phone-metadata">
35    <exec executable="java">
36      <arg value="-jar" />
37      <arg value="${build.tools.jar}"/>
38      <arg value="BuildMetadataProtoFromXml"/>
39      <arg value="--input-file=${resources.dir}/PhoneNumberMetadata.xml"/>
40      <arg value="--output-dir=${libphonenumber.src.dir}/com/google/i18n/phonenumbers"/>
41      <arg value="--data-prefix=data/PhoneNumberMetadataProto"/>
42      <arg value="--mapping-class=CountryCodeToRegionCodeMap"/>
43      <arg value="--copyright=2010"/>
44      <arg value="--lite-build=false"/>
45    </exec>
46  </target>
47
48  <target name="build-short-metadata">
49    <exec executable="java">
50      <arg value="-jar" />
51      <arg value="${build.tools.jar}"/>
52      <arg value="BuildMetadataProtoFromXml"/>
53      <arg value="--input-file=${resources.dir}/ShortNumberMetadata.xml"/>
54      <arg value="--output-dir=${libphonenumber.src.dir}/com/google/i18n/phonenumbers"/>
55      <arg value="--data-prefix=data/ShortNumberMetadataProto"/>
56      <arg value="--mapping-class=ShortNumbersRegionCodeSet"/>
57      <arg value="--copyright=2013"/>
58      <arg value="--lite-build=false"/>
59    </exec>
60  </target>
61
62  <target name="build-test-metadata">
63    <exec executable="java">
64      <arg value="-jar" />
65      <arg value="${build.tools.jar}"/>
66      <arg value="BuildMetadataProtoFromXml"/>
67      <arg value="--input-file=${resources.dir}/PhoneNumberMetadataForTesting.xml"/>
68      <arg value="--output-dir=${libphonenumber.test.dir}/com/google/i18n/phonenumbers"/>
69      <arg value="--data-prefix=data/PhoneNumberMetadataProtoForTesting"/>
70      <arg value="--mapping-class=CountryCodeToRegionCodeMapForTesting"/>
71      <arg value="--copyright=2010"/>
72      <arg value="--lite-build=false"/>
73    </exec>
74  </target>
75
76  <target name="build-alternate-metadata">
77    <exec executable="java">
78      <arg value="-jar" />
79      <arg value="${build.tools.jar}"/>
80      <arg value="BuildMetadataProtoFromXml"/>
81      <arg value="--input-file=${resources.dir}/PhoneNumberAlternateFormats.xml"/>
82      <arg value="--output-dir=${libphonenumber.src.dir}/com/google/i18n/phonenumbers"/>
83      <arg value="--data-prefix=data/PhoneNumberAlternateFormatsProto"/>
84      <arg value="--mapping-class=AlternateFormatsCountryCodeSet"/>
85      <arg value="--copyright=2012"/>
86      <arg value="--lite-build=false"/>
87    </exec>
88  </target>
89
90  <target name="build-carrier-data">
91    <exec executable="java">
92      <arg value="-jar" />
93      <arg value="${build.tools.jar}"/>
94      <arg value="GeneratePhonePrefixData"/>
95      <arg value="${resources.dir}/carrier/"/>
96      <arg value="carrier/src/com/google/i18n/phonenumbers/carrier/data"/>
97    </exec>
98  </target>
99
100  <target name="build-carrier-test-data">
101    <exec executable="java">
102      <arg value="-jar" />
103      <arg value="${build.tools.jar}"/>
104      <arg value="GeneratePhonePrefixData"/>
105      <arg value="${resources.dir}/test/carrier/"/>
106      <arg value="carrier/test/com/google/i18n/phonenumbers/carrier/testing_data"/>
107    </exec>
108  </target>
109
110  <target name="build-geo-data">
111    <exec executable="java">
112      <arg value="-jar" />
113      <arg value="${build.tools.jar}"/>
114      <arg value="GeneratePhonePrefixData"/>
115      <arg value="${resources.dir}/geocoding/"/>
116      <arg value="geocoder/src/com/google/i18n/phonenumbers/geocoding/data"/>
117    </exec>
118  </target>
119
120  <target name="build-geo-test-data">
121    <exec executable="java">
122      <arg value="-jar" />
123      <arg value="${build.tools.jar}"/>
124      <arg value="GeneratePhonePrefixData"/>
125      <arg value="${resources.dir}/test/geocoding/"/>
126      <arg value="geocoder/test/com/google/i18n/phonenumbers/geocoding/testing_data"/>
127    </exec>
128  </target>
129
130  <target name="build-timezones-data">
131    <exec executable="java">
132      <arg value="-jar" />
133      <arg value="${build.tools.jar}"/>
134      <arg value="GenerateTimeZonesMapData"/>
135      <arg value="${resources.dir}/timezones/map_data.txt"/>
136      <arg value="geocoder/src/com/google/i18n/phonenumbers/timezones/data"/>
137    </exec>
138  </target>
139
140  <target name="build-timezones-test-data">
141    <exec executable="java">
142      <arg value="-jar" />
143      <arg value="${build.tools.jar}"/>
144      <arg value="GenerateTimeZonesMapData"/>
145      <arg value="${resources.dir}/test/timezones/map_data.txt"/>
146      <arg value="geocoder/test/com/google/i18n/phonenumbers/timezones/testing_data"/>
147    </exec>
148  </target>
149
150  <target name="build-js-metadata">
151    <exec executable="java">
152      <arg value="-jar" />
153      <arg value="${build.tools.jar}"/>
154      <arg value="BuildMetadataJsonFromXml"/>
155      <arg value="${resources.dir}/PhoneNumberMetadata.xml"/>
156      <arg value="${javascript.dir}/i18n/phonenumbers/metadata.js"/>
157    </exec>
158    <exec executable="java">
159      <arg value="-jar" />
160      <arg value="${build.tools.jar}"/>
161      <arg value="BuildMetadataJsonFromXml"/>
162      <arg value="${resources.dir}/PhoneNumberMetadata.xml"/>
163      <arg value="${javascript.dir}/i18n/phonenumbers/metadatalite.js"/>
164      <arg value="true"/> <!-- Lite metadata. -->
165    </exec>
166    <exec executable="java">
167      <arg value="-jar" />
168      <arg value="${build.tools.jar}"/>
169      <arg value="BuildMetadataJsonFromXml"/>
170      <arg value="${resources.dir}/PhoneNumberMetadataForTesting.xml"/>
171      <arg value="${javascript.dir}/i18n/phonenumbers/metadatafortesting.js"/>
172    </exec>
173  </target>
174
175  <target name="compile" description="Compile Java source."
176          depends="build-phone-metadata,build-short-metadata,build-alternate-metadata,build-carrier-data,build-geo-data,build-timezones-data">
177    <mkdir dir="${classes.dir}"/>
178    <javac srcdir="${libphonenumber.src.dir};${carrier.src.dir};${geocoder.src.dir};${prefixmapper.src.dir}"
179           destdir="${classes.dir}" classpathref="classpath" includeAntRuntime="false"/>
180    <javac srcdir="${libphonenumber.test.dir};${carrier.test.dir};${geocoder.test.dir};${prefixmapper.test.dir}"
181           destdir="${classes.dir}" classpathref="classpath" debug="on"
182           includeAntRuntime="false"/>
183  </target>
184
185  <target name="jar" depends="compile">
186    <mkdir dir="${jar.dir}"/>
187    <jar destfile="${jar.dir}/${ant.project.name}.jar">
188      <fileset dir="${classes.dir}">
189        <include name="**/*.class"/>
190        <exclude name="**/*Test*"/>
191        <exclude name="**/BuildMetadata*"/>
192        <exclude name="**/PhoneNumberTo*"/>
193        <exclude name="**/geocoding/*"/>
194        <exclude name="**/prefixmapper/*"/>
195      </fileset>
196      <fileset dir="${libphonenumber.src.dir}">
197        <include name="**/PhoneNumberMetadataProto*"/>
198        <include name="**/PhoneNumberAlternateFormatsProto*"/>
199        <include name="**/ShortNumberMetadataProto*"/>
200      </fileset>
201    </jar>
202    <jar destfile="${jar.dir}/carrier-mapper.jar">
203      <fileset dir="${classes.dir}">
204        <include name="**/PhoneNumberToCarrierMapper.class"/>
205        <include name="**/prefixmapper/*.class"/>
206        <exclude name="**/*Test*"/>
207      </fileset>
208      <fileset dir="${carrier.src.dir}">
209        <include name="**/carrier/data/*"/>
210      </fileset>
211    </jar>
212    <jar destfile="${jar.dir}/offline-geocoder.jar">
213      <fileset dir="${classes.dir}">
214        <include name="**/geocoding/*.class"/>
215        <include name="**/PhoneNumberToTimeZonesMapper*"/>
216        <include name="**/prefixmapper/*.class"/>
217        <exclude name="**/*Test*"/>
218      </fileset>
219      <fileset dir="${geocoder.src.dir}">
220        <include name="**/geocoding/data/*"/>
221        <include name="**/timezones/data/*"/>
222      </fileset>
223    </jar>
224  </target>
225
226  <target name="test-jar"
227          depends="compile,build-test-metadata,build-carrier-test-data,build-geo-test-data,build-timezones-test-data">
228    <mkdir dir="${jar.dir}"/>
229    <jar destfile="${jar.dir}/${ant.project.name}-test.jar">
230      <fileset dir="${classes.dir}">
231        <include name="**/*.class"/>
232        <exclude name="**/*Test*"/>
233      </fileset>
234      <fileset dir="${libphonenumber.src.dir}">
235        <include name="**/PhoneNumberMetadataProto*"/>
236        <include name="**/PhoneNumberAlternateFormatsProto*"/>
237        <include name="**/ShortNumberMetadataProto*"/>
238      </fileset>
239      <fileset dir="${libphonenumber.test.dir}">
240        <include name="**/PhoneNumberMetadataProtoForTesting*"/>
241      </fileset>
242      <fileset dir="${carrier.test.dir}">
243        <include name="**/carrier/testing_data/*"/>
244      </fileset>
245      <fileset dir="${geocoder.test.dir}">
246        <include name="**/geocoding/testing_data/*"/>
247        <include name="**/timezones/testing_data/*"/>
248      </fileset>
249    </jar>
250  </target>
251
252  <target name="junit" depends="test-jar">
253    <mkdir dir="${report.dir}"/>
254    <junit printsummary="yes"
255        failureProperty="test.failed" errorProperty="test.failed">
256      <classpath refid="test.classpath"/>
257      <formatter type="xml"/>
258      <batchtest fork="no" todir="${report.dir}">
259        <fileset dir="${libphonenumber.test.dir}" includes="**/*Test.java"/>
260      </batchtest>
261      <batchtest fork="no" todir="${report.dir}">
262        <fileset dir="${carrier.test.dir}" includes="**/*Test.java"/>
263      </batchtest>
264      <batchtest fork="no" todir="${report.dir}">
265        <fileset dir="${geocoder.test.dir}" includes="**/*Test.java"/>
266      </batchtest>
267      <batchtest fork="no" todir="${report.dir}">
268        <fileset dir="${prefixmapper.test.dir}" includes="**/*Test.java"/>
269      </batchtest>
270    </junit>
271    <fail message="Tests failed. Run 'ant junitreport' for more info."
272        if="test.failed"/>
273  </target>
274
275  <target name="junitreport">
276    <junitreport todir="${report.dir}">
277      <fileset dir="${report.dir}" includes="TEST-*.xml"/>
278        <report todir="${report.dir}"/>
279    </junitreport>
280  </target>
281
282  <target name="testname" unless="test">
283    <fail message="You must run this target with -Dtest=TestName"/>
284  </target>
285
286  <target name="test" depends="test-jar, testname">
287    <junit printsummary="withOutAndErr">
288      <classpath refid="test.classpath"/>
289      <formatter type="plain" usefile="false"/>
290      <batchtest fork="no">
291        <fileset dir="${libphonenumber.test.dir}" includes="**/*${test}.java"/>
292        <fileset dir="${carrier.test.dir}" includes="**/*${test}.java"/>
293        <fileset dir="${geocoder.test.dir}" includes="**/*${test}.java"/>
294      </batchtest>
295    </junit>
296  </target>
297
298  <target name="clean" description="Remove generated files.">
299    <delete dir="${build.dir}"/>
300  </target>
301
302  <target name="clean-build" depends="clean,jar"/>
303</project>
304