1<!--
2*******************************************************************************
3* Copyright (C) 2009-2014, International Business Machines Corporation and    *
4* others. All Rights Reserved.                                                *
5*******************************************************************************
6-->
7<project name="common-targets" basedir=".">
8    <dirname property="common-targets.dir" file="${ant.file.common-targets}"/>
9    <property file="${common-targets.dir}/locations.properties"/>
10
11    <!-- global (top-level) propeties - need locations.properties loaded first -->
12    <property file="${global.build-local.properties}"/>
13    <property file="${global.build.properties}"/>
14
15    <property file="${common-targets.dir}/common.properties"/>
16    <property environment="env"/>
17
18    <!-- common targets -->
19
20    <target name="@clean">
21        <delete dir="${out.dir}"/>
22    </target>
23
24    <target name="@compile">
25        <echo message="build-local:     ${global.build-local.properties}"/>
26        <echo message="${java5.bootclasspath}"/>
27        <!-- set java5/6 bootclasspath to empty if not set -->
28        <property name="java5.bootclasspath" value=""/>
29        <property name="java6.bootclasspath" value=""/>
30
31        <condition property="javac.bootclasspath" value="${java5.bootclasspath}">
32            <equals arg1="${javac.target}" arg2="1.5"/>
33        </condition>
34        <condition property="javac.bootclasspath" value="${java6.bootclasspath}" else="">
35            <equals arg1="${javac.target}" arg2="1.6"/>
36        </condition>
37
38        <echo message="--- java compiler arguments ------------------------"/>
39        <echo message="source dir:     ${basedir}/${src.dir}"/>
40        <echo message="output dir:     ${basedir}/${bin.dir}"/>
41        <echo message="bootclasspath:  ${javac.bootclasspath}"/>
42        <echo message="classpath:      ${toString:javac.classpathref}"/>
43        <echo message="source:         ${javac.source}"/>
44        <echo message="target:         ${javac.target}"/>
45        <echo message="debug:          ${javac.debug}"/>
46        <echo message="encoding:       ${java.src.encoding}"/>
47        <echo message="compiler arg:   ${javac.compilerarg}"/>
48        <echo message="----------------------------------------------------"/>
49
50        <mkdir dir="${bin.dir}"/>
51        <javac
52            srcdir="${src.dir}"
53            destdir="${bin.dir}"
54            bootclasspath="${javac.bootclasspath}"
55            classpathref="javac.classpathref"
56            source="${javac.source}"
57            target="${javac.target}"
58            debug="${javac.debug}"
59            encoding="${java.src.encoding}"
60            includeAntRuntime="no">
61            <compilerarg value="${javac.compilerarg}"/>
62        </javac>
63    </target>
64
65    <target name="@copy">
66        <mkdir dir="${bin.dir}"/>
67        <copy todir="${bin.dir}">
68            <fileset dir="${src.dir}" defaultexcludes="yes">
69                <exclude name="**/*.java"/>
70            </fileset>
71        </copy>
72    </target>
73
74    <target name="@jar">
75        <mkdir dir="${jar.dir}"/>
76
77        <copy file="manifest.stub" todir="${out.dir}">
78            <filterset>
79                <filter token="SPECVERSION" value="${jar.spec.version}"/>
80                <filter token="IMPLVERSION" value="${jar.impl.version}"/>
81                <filter token="COPYRIGHT" value="${jar.copyright.info}"/>
82                <filter token="EXECENV" value="${jar.exec.env}"/>
83            </filterset>
84        </copy>
85
86        <jar jarfile="${jar.dir}/${jar.name}" manifest="${out.dir}/manifest.stub" compress="true">
87            <fileset dir="${bin.dir}" includes="**/*"/>
88            <fileset dir="${shared.dir}/licenses">
89                <include name="license.html"/>
90            </fileset>
91        </jar>
92    </target>
93
94    <target name="@src-jar">
95        <mkdir dir="${jar.dir}"/>
96        <jar jarfile="${jar.dir}/${src.jar.name}" compress="true">
97            <fileset dir="${src.dir}" includes="**/*.java"/>
98            <fileset dir="${shared.dir}/licenses">
99                <include name="license.html"/>
100            </fileset>
101        </jar>
102    </target>
103
104    <target name="@build-all">
105        <antcall target="_all.${ant.project.name}"/>
106    </target>
107
108    <target name="@full-locale-names">
109        <echo message="Generating ${res.dir}/fullLocaleNames.lst"/>
110        <pathconvert pathsep="${line.separator}" property="full.locale.names">
111            <fileset dir="${res.dir}">
112                <include name="??.res"/>
113                <include name="??_*.res"/>
114                <include name="???.res"/>
115                <include name="???_*.res"/>
116                <include name="root.res"/>
117                <exclude name="res_index.res"/>
118            </fileset>
119            <chainedmapper>
120                <flattenmapper/>
121                <globmapper from="*.res" to="*"/>
122            </chainedmapper>
123        </pathconvert>
124        <echo message="${full.locale.names}" file="${res.dir}/fullLocaleNames.lst"/>
125    </target>
126
127    <!-- FindBugs targets -->
128    <target name="_findbugs_init">
129        <property name="findbugs.home" value="${env.FINDBUGS_HOME}"/>
130        <echo message="----------------------------------------------------"/>
131        <echo message="findbugs.home:  ${findbugs.home}"/>
132        <echo message="----------------------------------------------------"/>
133
134        <fail message="FindBugs task not found. Set environment variable FINDBUGS_HOME properly.">
135            <condition>
136                <not>
137                    <or>
138                        <available classname="edu.umd.cs.findbugs.anttask.FindBugsTask" property="_findbugs.task.available" />
139                        <available file="${findbugs.home}/lib/findbugs-ant.jar" />
140                    </or>
141                </not>
142            </condition>
143        </fail>
144        <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"
145            classpath="${findbugs.home}/lib/findbugs-ant.jar"/>
146
147        <property name="aux.classpath" value="${toString:javac.classpathref}"/>
148        <condition property="empty.aux.classpath">
149            <length string="${aux.classpath}" when="eq" length="0"/>
150        </condition>
151    </target>
152
153    <target name="_findbugs_empty_aux_classpath" if="empty.aux.classpath">
154        <findbugs
155            home="${findbugs.home}"
156            output="html"
157            outputFile="${out.dir}/fb-${ant.project.name}.html"
158            excludeFilter="findbugs-exclude.xml">
159
160            <sourcePath path="${src.dir}"/>
161            <class location="${jar.dir}/${jar.name}"/>
162        </findbugs>
163    </target>
164
165    <target name="_findbugs_non_empty_aux_classpath" unless="empty.aux.classpath">
166        <findbugs
167            home="${findbugs.home}"
168            output="html"
169            outputFile="${out.dir}/fb-${ant.project.name}.html"
170            excludeFilter="findbugs-exclude.xml">
171
172            <sourcePath path="${src.dir}"/>
173            <class location="${jar.dir}/${jar.name}"/>
174            <auxClasspath path="${aux.classpath}"/>
175        </findbugs>
176    </target>
177
178    <target name="@findbugs" depends="_findbugs_init, @build-all, _findbugs_empty_aux_classpath, _findbugs_non_empty_aux_classpath"/>
179
180    <!-- Dependencies -->
181
182    <!-- collate -->
183    <path id="javac.classpathref.collate">
184        <pathelement location="${icu4j.core.jar}"/>
185    </path>
186
187    <target name="_all.collate" depends="_all.core">
188        <ant dir="${icu4j.collate.dir}" inheritAll="false"/>
189    </target>
190
191    <!-- core -->
192    <path id="javac.classpathref.core"/>
193
194    <target name="_all.core">
195        <ant dir="${icu4j.core.dir}" inheritAll="false"/>
196    </target>
197
198    <!-- charset -->
199    <path id="javac.classpathref.charset">
200        <pathelement location="${icu4j.core.jar}"/>
201    </path>
202
203    <target name="_all.charset" depends="_all.core">
204        <ant dir="${icu4j.charset.dir}" inheritAll="false"/>
205    </target>
206
207    <!-- currdata -->
208    <path id="javac.classpathref.currdata">
209        <pathelement location="${icu4j.core.jar}"/>
210    </path>
211
212    <target name="_all.currdata" depends="_all.core">
213        <ant dir="${icu4j.currdata.dir}" inheritAll="false"/>
214    </target>
215
216    <!-- langdata -->
217    <path id="javac.classpathref.langdata">
218        <pathelement location="${icu4j.core.jar}"/>
219    </path>
220
221    <target name="_all.langdata" depends="_all.core">
222        <ant dir="${icu4j.langdata.dir}" inheritAll="false"/>
223    </target>
224
225    <!-- localespi -->
226    <path id="javac.classpathref.localespi">
227        <pathelement location="${icu4j.core.jar}"/>
228        <pathelement location="${icu4j.collate.jar}"/>
229    </path>
230
231    <target name="_all.localespi" depends="_all.core, _all.collate">
232        <ant dir="${icu4j.localespi.dir}" inheritAll="false"/>
233    </target>
234
235    <!-- regiondata -->
236    <path id="javac.classpathref.regiondata">
237        <pathelement location="${icu4j.core.jar}"/>
238    </path>
239
240    <target name="_all.regiondata" depends="_all.core">
241        <ant dir="${icu4j.regiondata.dir}" inheritAll="false"/>
242    </target>
243
244    <!-- translit -->
245    <path id="javac.classpathref.translit">
246        <pathelement location="${icu4j.core.jar}"/>
247        <pathelement location="${icu4j.translit.jar}"/>
248    </path>
249
250    <target name="_all.translit" depends="_all.core">
251        <ant dir="${icu4j.translit.dir}" inheritAll="false"/>
252    </target>
253
254    <!-- test-framework -->
255    <path id="javac.classpathref.test-framework">
256        <pathelement location="${icu4j.core.jar}"/>
257    </path>
258
259    <target name="_all.test-framework" depends="_all.core">
260        <ant dir="${icu4j.test-framework.dir}" inheritAll = "false"/>
261    </target>
262
263    <!-- core-tests -->
264    <path id="javac.classpathref.core-tests">
265        <pathelement location="${icu4j.core.jar}"/>
266        <pathelement location="${icu4j.test-framework.jar}"/>
267    </path>
268
269    <target name="_all.core-tests" depends="_all.core, _all.test-framework">
270        <ant dir="${icu4j.core-tests.dir}" inheritAll="false"/>
271    </target>
272
273    <!-- collate-tests -->
274    <path id="javac.classpathref.collate-tests">
275        <pathelement location="${icu4j.core.jar}"/>
276        <pathelement location="${icu4j.collate.jar}"/>
277        <pathelement location="${icu4j.test-framework.jar}"/>
278    </path>
279
280    <target name="_all.collate-tests" depends="_all.core, _all.collate, _all.test-framework">
281        <ant dir="${icu4j.collate-tests.dir}" inheritAll="false"/>
282    </target>
283
284    <!-- charset-tests -->
285    <path id="javac.classpathref.charset-tests">
286        <pathelement location="${icu4j.core.jar}"/>
287        <pathelement location="${icu4j.charset.jar}"/>
288        <pathelement location="${icu4j.test-framework.jar}"/>
289    </path>
290
291    <target name="_all.charset-tests" depends="_all.core, _all.charset, _all.test-framework">
292        <ant dir="${icu4j.charset-tests.dir}" inheritAll="false"/>
293    </target>
294
295    <!-- localespi-tests -->
296    <path id="javac.classpathref.localespi-tests">
297        <pathelement location="${icu4j.core.jar}"/>
298	<pathelement location="${icu4j.collate.jar}"/>
299        <pathelement location="${icu4j.localespi.jar}"/>
300        <pathelement location="${icu4j.test-framework.jar}"/>
301    </path>
302
303    <target name="_all.localespi-tests" depends="_all.core, _all.collate, _all.localespi, _all.test-framework">
304        <ant dir="${icu4j.localespi-tests.dir}" inheritAll="false"/>
305    </target>
306
307    <!-- packaging-tests -->
308    <path id="javac.classpathref.packaging-tests">
309        <pathelement location="${icu4j.core.jar}"/>
310        <pathelement location="${icu4j.charset.jar}"/>
311        <pathelement location="${icu4j.test-framework.jar}"/>
312    </path>
313
314    <target name="_all.packaging-tests" depends="_all.core, _all.charset, _all.test-framework">
315        <ant dir="${icu4j.packaging-tests.dir}" inheritAll="false"/>
316    </target>
317
318    <!-- translit-tests -->
319    <path id="javac.classpathref.translit-tests">
320        <pathelement location="${icu4j.core.jar}"/>
321        <pathelement location="${icu4j.translit.jar}"/>
322        <pathelement location="${icu4j.test-framework.jar}"/>
323    </path>
324
325    <target name="_all.translit-tests" depends="_all.core, _all.translit, _all.test-framework">
326        <ant dir="${icu4j.translit-tests.dir}" inheritAll="false"/>
327    </target>
328
329    <!-- testall -->
330    <path id="javac.classpathref.testall">
331        <pathelement location="${icu4j.core.jar}"/>
332        <pathelement location="${icu4j.test-framework.jar}"/>
333    </path>
334
335    <target name="_all.testall" depends="_all.core, _all.test-framework">
336        <ant dir="${icu4j.testall.dir}" inheritAll="false"/>
337    </target>
338
339
340    <!-- build-tools -->
341    <path id="javac.classpathref.build-tools">
342        <pathelement location="${env.JAVA_HOME}/lib/tools.jar"/>
343    </path>
344
345    <target name="_all.build-tools">
346        <ant dir="${icu4j.build-tools.dir}" inheritAll="false"/>
347    </target>
348
349    <!-- tools -->
350    <path id="javac.classpathref.tools">
351        <pathelement location="${icu4j.core.jar}"/>
352        <pathelement location="${icu4j.collate.jar}"/>
353        <pathelement location="${icu4j.translit.jar}"/>
354        <pathelement location="${icu4j.test-framework.jar}"/>
355        <pathelement location="${icu4j.core-tests.jar}"/>
356        <pathelement location="${icu4j.translit-tests.jar}"/>
357    </path>
358
359    <target name="_all.tools" depends="_all.core, _all.collate, _all.translit, _all.test-framework, _all.core-tests, _all.translit-tests">
360        <ant dir="${icu4j.tools.dir}" inheritAll="false"/>
361    </target>
362
363    <!-- demos -->
364    <path id="javac.classpathref.demos">
365        <pathelement location="${icu4j.core.jar}"/>
366        <pathelement location="${icu4j.translit.jar}"/>
367        <pathelement location="${icu4j.charset.jar}"/>
368    </path>
369
370    <target name="_all.demos" depends="_all.core, _all.translit, _all.charset">
371        <ant dir="${icu4j.demos.dir}" inheritAll="false"/>
372    </target>
373
374    <!-- samples -->
375    <path id="javac.classpathref.samples">
376        <pathelement location="${icu4j.core.jar}"/>
377        <pathelement location="${icu4j.collate.jar}"/>
378        <pathelement location="${icu4j.translit.jar}"/>
379        <pathelement location="${icu4j.charset.jar}"/>
380    </path>
381
382    <target name="_all.samples" depends="_all.core, _all.collate, _all.translit, _all.charset">
383        <ant dir="${icu4j.samples.dir}" inheritAll="false"/>
384    </target>
385
386    <!-- perf -->
387    <path id="javac.classpathref.perf-tests">
388        <pathelement location="${icu4j.core.jar}"/>
389        <pathelement location="${icu4j.charset.jar}"/>
390        <pathelement location="${icu4j.collate.jar}"/>
391        <pathelement location="${icu4j.tools.jar}"/>
392    </path>
393
394    <target name="_all.perf-tests" depends="_all.core, _all.charset, _all.collate, _all.tools">
395        <ant dir="${icu4j.perf-tests.dir}" inheritAll="false"/>
396    </target>
397
398</project>
399