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 <delete dir="carrier/src/com/google/i18n/phonenumbers/carrier/data"/> 92 <exec executable="java"> 93 <arg value="-jar" /> 94 <arg value="${build.tools.jar}"/> 95 <arg value="GeneratePhonePrefixData"/> 96 <arg value="${resources.dir}/carrier/"/> 97 <arg value="carrier/src/com/google/i18n/phonenumbers/carrier/data"/> 98 </exec> 99 </target> 100 101 <target name="build-carrier-test-data"> 102 <delete dir="carrier/test/com/google/i18n/phonenumbers/carrier/testing_data"/> 103 <exec executable="java"> 104 <arg value="-jar" /> 105 <arg value="${build.tools.jar}"/> 106 <arg value="GeneratePhonePrefixData"/> 107 <arg value="${resources.dir}/test/carrier/"/> 108 <arg value="carrier/test/com/google/i18n/phonenumbers/carrier/testing_data"/> 109 </exec> 110 </target> 111 112 <target name="build-geo-data"> 113 <delete dir="geocoder/src/com/google/i18n/phonenumbers/geocoding/data"/> 114 <exec executable="java"> 115 <arg value="-jar" /> 116 <arg value="${build.tools.jar}"/> 117 <arg value="GeneratePhonePrefixData"/> 118 <arg value="${resources.dir}/geocoding/"/> 119 <arg value="geocoder/src/com/google/i18n/phonenumbers/geocoding/data"/> 120 </exec> 121 </target> 122 123 <target name="build-geo-test-data"> 124 <delete dir="geocoder/test/com/google/i18n/phonenumbers/geocoding/testing_data"/> 125 <exec executable="java"> 126 <arg value="-jar" /> 127 <arg value="${build.tools.jar}"/> 128 <arg value="GeneratePhonePrefixData"/> 129 <arg value="${resources.dir}/test/geocoding/"/> 130 <arg value="geocoder/test/com/google/i18n/phonenumbers/geocoding/testing_data"/> 131 </exec> 132 </target> 133 134 <target name="build-timezones-data"> 135 <exec executable="java"> 136 <arg value="-jar" /> 137 <arg value="${build.tools.jar}"/> 138 <arg value="GenerateTimeZonesMapData"/> 139 <arg value="${resources.dir}/timezones/map_data.txt"/> 140 <arg value="geocoder/src/com/google/i18n/phonenumbers/timezones/data"/> 141 </exec> 142 </target> 143 144 <target name="build-timezones-test-data"> 145 <exec executable="java"> 146 <arg value="-jar" /> 147 <arg value="${build.tools.jar}"/> 148 <arg value="GenerateTimeZonesMapData"/> 149 <arg value="${resources.dir}/test/timezones/map_data.txt"/> 150 <arg value="geocoder/test/com/google/i18n/phonenumbers/timezones/testing_data"/> 151 </exec> 152 </target> 153 154 <target name="build-js-metadata"> 155 <exec executable="java"> 156 <arg value="-jar" /> 157 <arg value="${build.tools.jar}"/> 158 <arg value="BuildMetadataJsonFromXml"/> 159 <arg value="${resources.dir}/PhoneNumberMetadata.xml"/> 160 <arg value="${javascript.dir}/i18n/phonenumbers/metadata.js"/> 161 </exec> 162 <exec executable="java"> 163 <arg value="-jar" /> 164 <arg value="${build.tools.jar}"/> 165 <arg value="BuildMetadataJsonFromXml"/> 166 <arg value="${resources.dir}/PhoneNumberMetadata.xml"/> 167 <arg value="${javascript.dir}/i18n/phonenumbers/metadatalite.js"/> 168 <arg value="true"/> <!-- Lite metadata. --> 169 </exec> 170 <exec executable="java"> 171 <arg value="-jar" /> 172 <arg value="${build.tools.jar}"/> 173 <arg value="BuildMetadataJsonFromXml"/> 174 <arg value="${resources.dir}/ShortNumberMetadata.xml"/> 175 <arg value="${javascript.dir}/i18n/phonenumbers/shortnumbermetadata.js"/> 176 <arg value="false"/> <!-- Lite metadata. --> 177 <arg value="i18n.phonenumbers.shortnumbermetadata" /> <!-- namespace to provide --> 178 </exec> 179 <exec executable="java"> 180 <arg value="-jar" /> 181 <arg value="${build.tools.jar}"/> 182 <arg value="BuildMetadataJsonFromXml"/> 183 <arg value="${resources.dir}/PhoneNumberMetadataForTesting.xml"/> 184 <arg value="${javascript.dir}/i18n/phonenumbers/metadatafortesting.js"/> 185 </exec> 186 </target> 187 188 <target name="compile" description="Compile Java source." 189 depends="build-phone-metadata,build-short-metadata,build-alternate-metadata,build-carrier-data,build-geo-data,build-timezones-data"> 190 <mkdir dir="${classes.dir}"/> 191 <javac srcdir="${libphonenumber.src.dir};${carrier.src.dir};${geocoder.src.dir};${prefixmapper.src.dir}" 192 destdir="${classes.dir}" classpathref="classpath" includeAntRuntime="false" encoding="UTF-8"/> 193 <javac srcdir="${libphonenumber.test.dir};${carrier.test.dir};${geocoder.test.dir};${prefixmapper.test.dir}" 194 destdir="${classes.dir}" classpathref="classpath" debug="on" 195 includeAntRuntime="false"/> 196 </target> 197 198 <target name="jar" depends="compile"> 199 <mkdir dir="${jar.dir}"/> 200 <jar destfile="${jar.dir}/${ant.project.name}.jar"> 201 <fileset dir="${classes.dir}"> 202 <include name="**/*.class"/> 203 <exclude name="**/*Test*"/> 204 <exclude name="**/BuildMetadata*"/> 205 <exclude name="**/PhoneNumberTo*"/> 206 <exclude name="**/geocoding/*"/> 207 <exclude name="**/prefixmapper/*"/> 208 </fileset> 209 <fileset dir="${libphonenumber.src.dir}"> 210 <include name="**/PhoneNumberMetadataProto*"/> 211 <include name="**/PhoneNumberAlternateFormatsProto*"/> 212 <include name="**/ShortNumberMetadataProto*"/> 213 </fileset> 214 </jar> 215 <jar destfile="${jar.dir}/carrier-mapper.jar"> 216 <fileset dir="${classes.dir}"> 217 <include name="**/PhoneNumberToCarrierMapper.class"/> 218 <include name="**/prefixmapper/*.class"/> 219 <exclude name="**/*Test*"/> 220 </fileset> 221 <fileset dir="${carrier.src.dir}"> 222 <include name="**/carrier/data/*"/> 223 </fileset> 224 </jar> 225 <jar destfile="${jar.dir}/offline-geocoder.jar"> 226 <fileset dir="${classes.dir}"> 227 <include name="**/geocoding/*.class"/> 228 <include name="**/PhoneNumberToTimeZonesMapper*"/> 229 <include name="**/prefixmapper/*.class"/> 230 <exclude name="**/*Test*"/> 231 </fileset> 232 <fileset dir="${geocoder.src.dir}"> 233 <include name="**/geocoding/data/*"/> 234 <include name="**/timezones/data/*"/> 235 </fileset> 236 </jar> 237 </target> 238 239 <target name="test-jar" 240 depends="compile,build-test-metadata,build-carrier-test-data,build-geo-test-data,build-timezones-test-data"> 241 <mkdir dir="${jar.dir}"/> 242 <jar destfile="${jar.dir}/${ant.project.name}-test.jar"> 243 <fileset dir="${classes.dir}"> 244 <include name="**/*.class"/> 245 <exclude name="**/*Test*"/> 246 </fileset> 247 <fileset dir="${libphonenumber.src.dir}"> 248 <include name="**/PhoneNumberMetadataProto*"/> 249 <include name="**/PhoneNumberAlternateFormatsProto*"/> 250 <include name="**/ShortNumberMetadataProto*"/> 251 </fileset> 252 <fileset dir="${libphonenumber.test.dir}"> 253 <include name="**/PhoneNumberMetadataProtoForTesting*"/> 254 </fileset> 255 <fileset dir="${carrier.test.dir}"> 256 <include name="**/carrier/testing_data/*"/> 257 </fileset> 258 <fileset dir="${geocoder.test.dir}"> 259 <include name="**/geocoding/testing_data/*"/> 260 <include name="**/timezones/testing_data/*"/> 261 </fileset> 262 </jar> 263 </target> 264 265 <target name="junit" depends="test-jar"> 266 <mkdir dir="${report.dir}"/> 267 <junit printsummary="yes" 268 failureProperty="test.failed" errorProperty="test.failed"> 269 <classpath refid="test.classpath"/> 270 <formatter type="xml"/> 271 <batchtest fork="no" todir="${report.dir}"> 272 <fileset dir="${libphonenumber.test.dir}" includes="**/*Test.java"/> 273 </batchtest> 274 <batchtest fork="no" todir="${report.dir}"> 275 <fileset dir="${carrier.test.dir}" includes="**/*Test.java"/> 276 </batchtest> 277 <batchtest fork="no" todir="${report.dir}"> 278 <fileset dir="${geocoder.test.dir}" includes="**/*Test.java"/> 279 </batchtest> 280 <batchtest fork="no" todir="${report.dir}"> 281 <fileset dir="${prefixmapper.test.dir}" includes="**/*Test.java"/> 282 </batchtest> 283 </junit> 284 <fail message="Tests failed. Run 'ant junitreport' for more info." 285 if="test.failed"/> 286 </target> 287 288 <target name="junitreport"> 289 <junitreport todir="${report.dir}"> 290 <fileset dir="${report.dir}" includes="TEST-*.xml"/> 291 <report todir="${report.dir}"/> 292 </junitreport> 293 </target> 294 295 <target name="testname" unless="test"> 296 <fail message="You must run this target with -Dtest=TestName"/> 297 </target> 298 299 <target name="test" depends="test-jar, testname"> 300 <junit printsummary="withOutAndErr"> 301 <classpath refid="test.classpath"/> 302 <formatter type="plain" usefile="false"/> 303 <batchtest fork="no"> 304 <fileset dir="${libphonenumber.test.dir}" includes="**/*${test}.java"/> 305 <fileset dir="${carrier.test.dir}" includes="**/*${test}.java"/> 306 <fileset dir="${geocoder.test.dir}" includes="**/*${test}.java"/> 307 </batchtest> 308 </junit> 309 </target> 310 311 <target name="clean" description="Remove generated files."> 312 <delete dir="${build.dir}"/> 313 </target> 314 315 <target name="clean-build" depends="clean,jar"/> 316</project> 317