1<!--
2/*
3*******************************************************************************
4* Copyright (C) 2010-2014, International Business Machines Corporation and    *
5* others. All Rights Reserved.                                                *
6*******************************************************************************
7*/
8-->
9
10<project name="icu4j-eclipse" default="build" basedir=".">
11  <property file="build-local.properties"/>
12  <property file="build.properties"/>
13
14  <property name="out.dir" value="out"/>
15  <property name="eclipse.projects.dir" value="${out.dir}/projects"/>
16
17  <property name="main.dir" value="../main"/>
18  <property name="shared.dir" value="${main.dir}/shared"/>
19
20  <import file="${shared.dir}/build/common-targets.xml"/>
21  <property file="${shared.dir}/build/common.properties"/>
22  <property file="${shared.dir}/build/locations.properties"/>
23
24  <property environment="env"/>
25
26  <target name="clean" description="Delete all build outputs">
27    <delete dir="${out.dir}"/>
28  </target>
29
30  <target name="build"
31          depends="checkProps,initEnv,icuProjectFiles,icuTestsProjectFiles,icuBaseProjectFiles,icuBaseTestsProjectFiles"
32          description="Build icu4j plug-ins">
33
34    <!-- copy OSGi jar file to baseLocation -->
35    <mkdir dir="${eclipse.projects.dir}/baseLocation/features"/>
36    <mkdir dir="${eclipse.projects.dir}/baseLocation/plugins"/>
37    <copy toDir="${eclipse.projects.dir}/baseLocation/plugins" file="${eclipse.osgi.jar}"/>
38
39    <!-- copy PDE build script files and run the build -->
40    <pathconvert property="eclipse.projects.dir.full" dirsep="/">
41      <path location="${basedir}/${eclipse.projects.dir}"/>
42    </pathconvert>
43
44    <antcall target="runEclipsePDEBuild">
45      <param name="icu.plugin.id" value="com.ibm.icu"/>
46    </antcall>
47
48    <antcall target="runEclipsePDEBuild">
49      <param name="icu.plugin.id" value="com.ibm.icu.base"/>
50    </antcall>
51
52  </target>
53
54  <target name="initEclipseHome"
55          if="env.ECLIPSE_HOME"
56          unless="eclipse.home"
57          description="Initialize the property eclipse.home from the environment variable ECLIPSE_HOME">
58    <property name="eclipse.home" value="${env.ECLIPSE_HOME}"/>
59  </target>
60
61  <target name="checkProps" depends="initEclipseHome">
62      <fail message="Eclipse home (eclipse.home or env.ECLIPSE_HOME) is not set">
63        <condition>
64          <or>
65            <equals arg1="${eclipse.home}" arg2=""/>
66            <not>
67              <isset property="eclipse.home"/>
68            </not>
69          </or>
70        </condition>
71      </fail>
72      <fail message="Java runtime jar path (java.rt) is not set">
73        <condition>
74          <or>
75            <equals arg1="${java.rt}" arg2=""/>
76            <not>
77              <isset property="java.rt"/>
78            </not>
79          </or>
80        </condition>
81      </fail>
82  </target>
83
84  <target name="initPluginVersion">
85    <tstamp>
86      <format property="build.date" pattern="yyyyMMdd"/>
87    </tstamp>
88    <property name="icu4j.eclipse.build.version.string" value="${icu4j.plugin.impl.version.string}.v${build.date}"/>
89  </target>
90
91  <target name="initEnv"
92          depends="checkProps,initEclipseLauncher,initEclipseOSGiJar,initEclipsePDE"
93          description="Initialize eclipse PDE build environment">
94    <echo message="[PDE build configuration properties]"/>
95    <echo message="    Ant version:     ${ant.version}"/>
96    <echo message="    Eclipse home:    ${eclipse.home}"/>
97    <echo message="    Launcher jar:    ${eclipse.launcher}"/>
98    <echo message="    OSGi bundle jar: ${eclipse.osgi.jar}"/>
99    <echo message="    Base OS:         ${eclipse.baseos}"/>
100    <echo message="    Base WS:         ${eclipse.basews}"/>
101    <echo message="    Base ARCH:       ${eclipse.basearch}"/>
102    <echo message="    java.rt:         ${java.rt}"/>
103
104    <!-- try and detect use of backslashes  -->
105    <condition property="java-rt-has-noSlashes">
106        <matches pattern="/" string="${java.rt}"/>
107    </condition>
108    <fail message="java.rt variable has no slashes!" unless="java-rt-has-noSlashes"/>
109
110  </target>
111
112  <target name="initEclipseLauncher"
113          if="eclipse.home"
114          description="Locate org.eclipse.equinox.launcher jar file for eclipse 3.3 and beyond">
115    <first id="equinox.launcher">
116      <fileset dir="${eclipse.home}/plugins">
117        <include name="org.eclipse.equinox.launcher_*.jar"/>
118      </fileset>
119    </first>
120    <pathconvert property="eclipse.launcher" dirsep="/" refid="equinox.launcher"/>
121  </target>
122
123  <target name="initEclipseOSGiJar"
124          if="eclipse.home"
125          description="Locate org.eclipse.osgi plugin jar file">
126    <first id="osgi.bundle">
127      <fileset dir="${eclipse.home}/plugins">
128        <include name="org.eclipse.osgi_*.jar"/>
129      </fileset>
130    </first>
131    <pathconvert property="eclipse.osgi.jar" dirsep="/" refid="osgi.bundle"/>
132  </target>
133
134  <target name="initEclipsePDE"
135          depends="locateEclipsePDE"
136          if="eclipse.pde.dir"
137          description="Set up PDE runtime arguments">
138    <property file="${eclipse.pde.dir}/templates/headless-build/build.properties" prefix="pde.template"/>
139    <property name="eclipse.baseos" value="${pde.template.baseos}"/>
140    <property name="eclipse.basews" value="${pde.template.basews}"/>
141    <property name="eclipse.basearch" value="${pde.template.basearch}"/>
142  </target>
143
144  <target name="locateEclipsePDE"
145          if="eclipse.home"
146          description="Locate org.eclipse.pde.build plug-in and set the property 'eclipse.pde.dir'">
147    <first id="eclipse.pde.plugin.dir">
148      <dirset dir="${eclipse.home}/plugins">
149        <include name="org.eclipse.pde.build_*"/>
150      </dirset>
151    </first>
152    <pathconvert property="eclipse.pde.dir" dirsep="/" refid="eclipse.pde.plugin.dir"/>
153  </target>
154
155  <target name="runEclipsePDEBuild">
156    <mkdir dir="${eclipse.projects.dir}/buildScripts/${icu.plugin.id}"/>
157      <copy toDir="${eclipse.projects.dir}/buildScripts/${icu.plugin.id}">
158        <fileset dir="pdebuild" includes="**/*"/>
159          <filterset>
160            <filter token="PLUGIN_ID" value="${icu.plugin.id}"/>
161            <filter token="BUILD_DIR" value="${eclipse.projects.dir.full}"/>
162            <filter token="BUILD_TYPE" value="ICU4J"/>
163            <filter token="BUILD_ID" value="${icu.plugin.id}"/>
164            <filter token="BASE_LOCATION" value="${eclipse.projects.dir.full}/baseLocation"/>
165            <filter token="BASE_OS" value="${eclipse.baseos}"/>
166            <filter token="BASE_WS" value="${eclipse.basews}"/>
167            <filter token="BASE_ARCH" value="${eclipse.basearch}"/>
168            <filter token="JAVA_RT" value="${java.rt}"/>
169          </filterset>
170      </copy>
171
172      <java jar="${eclipse.launcher}" fork="true" failonerror="true">
173        <arg value="-application"/>
174        <arg value="org.eclipse.ant.core.antRunner"/>
175        <arg value="-buildfile"/>
176        <arg value="${eclipse.pde.dir}/scripts/build.xml"/>
177        <arg value="-Dbuilder=${eclipse.projects.dir.full}/buildScripts/${icu.plugin.id}"/>
178      </java>
179  </target>
180
181  <target name="icuProjectFiles"
182        depends="initPluginVersion"
183        description="Copy com.ibm.icu plug-in project files">
184
185    <delete failonerror="no">
186      <fileset dir="${eclipse.projects.dir}/plugins/com.ibm.icu" />
187      <fileset dir="${eclipse.projects.dir}/features/com.ibm.icu" />
188    </delete>
189
190    <!-- icu source -->
191    <copy toDir="${eclipse.projects.dir}/plugins/com.ibm.icu/src">
192      <fileset dir="${icu4j.collate.dir}/src"/>
193      <fileset dir="${icu4j.core.dir}/src"/>
194      <fileset dir="${icu4j.currdata.dir}/src"/>
195      <fileset dir="${icu4j.langdata.dir}/src"/>
196      <fileset dir="${icu4j.regiondata.dir}/src"/>
197      <fileset dir="${icu4j.translit.dir}/src"/>
198    </copy>
199
200    <!-- overwriting the ICU runtime configuration file for forcing ICU4J plugin to use JDK time zone rules -->
201    <copy file="misc/ICUConfig.properties"
202      toDir="${eclipse.projects.dir}/plugins/com.ibm.icu/src/com/ibm/icu"
203      overwrite="true"/>
204
205    <!-- icu data -->
206    <unjar src="${icu4j.data.jar}" dest="${eclipse.projects.dir}/plugins/com.ibm.icu/src">
207      <patternset>
208        <exclude name="META-INF"/>
209        <exclude name="META-INF/**/*"/>
210        <exclude name="**/*.cnv"/>
211        <exclude name="**/cnvalias.icu"/>
212      </patternset>
213    </unjar>
214
215    <!-- icu tz data -->
216    <unjar src="${icu4j.tzdata.jar}" dest="${eclipse.projects.dir}/plugins/com.ibm.icu/src">
217      <patternset>
218        <exclude name="META-INF"/>
219        <exclude name="META-INF/**/*"/>
220      </patternset>
221    </unjar>
222
223    <!-- full locale names lists -->
224    <antcall target="@full-locale-names">
225        <param name="res.dir" value="${eclipse.projects.dir}/plugins/com.ibm.icu/src/${icu4j.data.path}"/>
226    </antcall>
227
228    <antcall target="@full-locale-names">
229        <param name="res.dir" value="${eclipse.projects.dir}/plugins/com.ibm.icu/src/${icu4j.data.path}/brkitr"/>
230    </antcall>
231
232    <antcall target="@full-locale-names">
233        <param name="res.dir" value="${eclipse.projects.dir}/plugins/com.ibm.icu/src/${icu4j.data.path}/coll"/>
234    </antcall>
235
236    <antcall target="@full-locale-names">
237        <param name="res.dir" value="${eclipse.projects.dir}/plugins/com.ibm.icu/src/${icu4j.data.path}/curr"/>
238    </antcall>
239
240    <antcall target="@full-locale-names">
241        <param name="res.dir" value="${eclipse.projects.dir}/plugins/com.ibm.icu/src/${icu4j.data.path}/lang"/>
242    </antcall>
243
244    <antcall target="@full-locale-names">
245        <param name="res.dir" value="${eclipse.projects.dir}/plugins/com.ibm.icu/src/${icu4j.data.path}/rbnf"/>
246    </antcall>
247
248    <antcall target="@full-locale-names">
249        <param name="res.dir" value="${eclipse.projects.dir}/plugins/com.ibm.icu/src/${icu4j.data.path}/region"/>
250    </antcall>
251
252    <antcall target="@full-locale-names">
253        <param name="res.dir" value="${eclipse.projects.dir}/plugins/com.ibm.icu/src/${icu4j.data.path}/translit"/>
254    </antcall>
255
256    <antcall target="@full-locale-names">
257        <param name="res.dir" value="${eclipse.projects.dir}/plugins/com.ibm.icu/src/${icu4j.data.path}/zone"/>
258    </antcall>
259
260    <!-- plugin project -->
261    <copy todir="${eclipse.projects.dir}/plugins/com.ibm.icu">
262      <fileset dir="plugins.template/com.ibm.icu"/>
263      <filterset>
264        <filter token="BUILD_VERSION" value="${icu4j.eclipse.build.version.string}" />
265        <filter token="COPYRIGHT" value="${copyright.eclipse}" />
266        <filter token="IMPL_VERSION" value="${icu4j.impl.version}" />
267        <filter token="DATA_VERSION_NUMBER" value="${icu4j.data.version.number}" />
268      </filterset>
269    </copy>
270
271    <!-- license -->
272    <copy file="${shared.dir}/licenses/license.html"
273          todir="${eclipse.projects.dir}/plugins/com.ibm.icu/about_files" />
274
275    <!-- about -->
276    <copy file="misc/about_icu.html"
277          tofile="${eclipse.projects.dir}/plugins/com.ibm.icu/about.html" />
278
279    <!-- FEATURE FILES -->
280    <copy todir="${eclipse.projects.dir}/features/com.ibm.icu">
281      <fileset dir="features.template/com.ibm.icu"/>
282      <filterset>
283        <filter token="BUILD_VERSION" value="${icu4j.eclipse.build.version.string}" />
284        <filter token="COPYRIGHT" value="${copyright.eclipse}" />
285        <filter token="DATA_VERSION_NUMBER" value="${icu4j.data.version.number}" />
286      </filterset>
287    </copy>
288
289  </target>
290
291  <target name="icuTestsProjectFiles"
292        depends="initPluginVersion"
293        description="Copy com.ibm.icu.tests plug-in project files">
294
295    <delete failonerror="no">
296      <fileset dir="${eclipse.projects.dir}/plugins/com.ibm.icu.tests" />
297    </delete>
298
299    <!-- icu test source -->
300    <copy toDir="${eclipse.projects.dir}/plugins/com.ibm.icu.tests/src">
301      <fileset dir="${icu4j.test-framework.dir}/src"/>
302      <fileset dir="${icu4j.core-tests.dir}/src"/>
303      <fileset dir="${icu4j.collate-tests.dir}/src"/>
304      <fileset dir="${icu4j.translit-tests.dir}/src"/>
305      <fileset dir="${icu4j.testall.dir}/src"/>
306    </copy>
307
308    <!-- icu test data -->
309    <unjar src="${icu4j.testdata.jar}" dest="${eclipse.projects.dir}/plugins/com.ibm.icu.tests/src">
310      <patternset>
311        <exclude name="**/*.cnv"/>
312        <exclude name="**/cnvalias.icu"/>
313        <exclude name="META-INF"/>
314        <exclude name="META-INF/**/*"/>
315      </patternset>
316    </unjar>
317
318    <!-- plugin project -->
319    <copy todir="${eclipse.projects.dir}/plugins/com.ibm.icu.tests">
320      <fileset dir="plugins.template/com.ibm.icu.tests"/>
321      <filterset>
322        <filter token="BUILD_VERSION" value="${icu4j.eclipse.build.version.string}" />
323        <filter token="COPYRIGHT" value="${copyright.eclipse}" />
324        <filter token="IMPL_VERSION" value="${icu4j.impl.version}" />
325        <filter token="DATA_VERSION_NUMBER" value="${icu4j.data.version.number}" />
326      </filterset>
327    </copy>
328
329    <!-- license -->
330    <copy file="${shared.dir}/licenses/license.html"
331          todir="${eclipse.projects.dir}/plugins/com.ibm.icu.tests/about_files" />
332
333    <!-- about -->
334    <copy file="misc/about_icu.html"
335          tofile="${eclipse.projects.dir}/plugins/com.ibm.icu.tests/about.html" />
336
337  </target>
338
339  <target name="icuBaseProjectFiles"
340        depends="initPluginVersion"
341        description="Copy com.ibm.icu.base plug-in project files">
342
343    <delete failonerror="no">
344      <fileset dir="${eclipse.projects.dir}/plugins/com.ibm.icu.base" />
345      <fileset dir="${eclipse.projects.dir}/features/com.ibm.icu.base" />
346    </delete>
347
348    <!-- plugin project -->
349    <copy todir="${eclipse.projects.dir}/plugins/com.ibm.icu.base">
350      <fileset dir="plugins.template/com.ibm.icu.base"/>
351      <filterset>
352        <filter token="BUILD_VERSION" value="${icu4j.eclipse.build.version.string}" />
353        <filter token="COPYRIGHT" value="${copyright.eclipse}" />
354        <filter token="IMPL_VERSION" value="${icu4j.impl.version}" />
355        <filter token="DATA_VERSION_NUMBER" value="${icu4j.data.version.number}" />
356      </filterset>
357    </copy>
358
359    <!-- license -->
360    <copy file="${shared.dir}/licenses/license.html"
361          todir="${eclipse.projects.dir}/plugins/com.ibm.icu.base/about_files" />
362
363    <!-- about -->
364    <copy file="misc/about_icu.html"
365          tofile="${eclipse.projects.dir}/plugins/com.ibm.icu.base/about.html" />
366
367    <!-- FEATURE FILES -->
368    <copy todir="${eclipse.projects.dir}/features/com.ibm.icu.base">
369      <fileset dir="features.template/com.ibm.icu.base"/>
370      <filterset>
371        <filter token="BUILD_VERSION" value="${icu4j.eclipse.build.version.string}" />
372        <filter token="COPYRIGHT" value="${copyright.eclipse}" />
373        <filter token="DATA_VERSION_NUMBER" value="${icu4j.data.version.number}" />
374      </filterset>
375    </copy>
376
377  </target>
378
379  <target name="icuBaseTestsProjectFiles"
380        depends="initPluginVersion"
381        description="Copy com.ibm.icu.base.tests plug-in project files">
382
383    <delete failonerror="no">
384      <fileset dir="${eclipse.projects.dir}/plugins/com.ibm.icu.base.tests" />
385    </delete>
386
387    <!-- plugin project -->
388    <copy todir="${eclipse.projects.dir}/plugins/com.ibm.icu.base.tests">
389      <fileset dir="plugins.template/com.ibm.icu.base.tests"/>
390      <filterset>
391        <filter token="BUILD_VERSION" value="${icu4j.eclipse.build.version.string}" />
392        <filter token="COPYRIGHT" value="${copyright.eclipse}" />
393        <filter token="IMPL_VERSION" value="${icu4j.impl.version}" />
394        <filter token="DATA_VERSION_NUMBER" value="${icu4j.data.version.number}" />
395      </filterset>
396    </copy>
397
398    <!-- license -->
399    <copy file="${shared.dir}/licenses/license.html"
400          todir="${eclipse.projects.dir}/plugins/com.ibm.icu.base.tests/about_files" />
401
402    <!-- about -->
403    <copy file="misc/about_icu.html"
404          tofile="${eclipse.projects.dir}/plugins/com.ibm.icu.base.tests/about.html" />
405
406  </target>
407
408</project>