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