blob: 48db7e16dd07399fc249cada136f5ceee3e86140 [file] [log] [blame]
Richard S. Hall6fe36b42009-07-13 13:25:46 +00001<?xml version="1.0"?>
2<!--
3 Licensed to the Apache Software Foundation (ASF) under one
4 or more contributor license agreements. See the NOTICE file
5 distributed with this work for additional information
6 regarding copyright ownership. The ASF licenses this file
7 to you under the Apache License, Version 2.0 (the
8 "License"); you may not use this file except in compliance
9 with the License. You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0
12
13 Unless required by applicable law or agreed to in writing,
14 software distributed under the License is distributed on an
15 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 KIND, either express or implied. See the License for the
17 specific language governing permissions and limitations
18 under the License.
19-->
David Morgan Spenser Savage3b1b8c82009-07-20 21:01:49 +000020<project name="bldcommon"
Richard S. Hall6fe36b42009-07-13 13:25:46 +000021 xmlns:ivy="antlib:org.apache.ivy.ant">
22
David Morgan Spenser Savage3b1b8c82009-07-20 21:01:49 +000023 <dirname property="common.dir" file="${ant.file.bldcommon}"/>
Richard S. Hall6fe36b42009-07-13 13:25:46 +000024 <property file="${common.dir}/sigil-defaults.properties" prefix="default."/>
25 <property file="${common.dir}/build.properties"/>
26
27 <!-- =====================================================
28 stuff intended to be over-ridden is prefixed with my.
29 =====================================================-->
30
31 <fileset id="my.projects" dir="${basedir}">
32 <include name="**/${build_xml}"/>
33 </fileset>
34
35 <path id="my.classpath">
36 <fileset dir="${basedir}" includes="lib/*.jar"/>
37 </path>
38
39 <path id="javac.classpath">
40 <path refid="my.classpath"/>
41 <fileset dir="${deps.dir}" />
42 </path>
43
44 <path id="sigil.classpath">
45 <path refid="javac.classpath" />
46 <path location="${classes.dir}" />
47 </path>
48
49 <!-- =================================
50 target: load-ivy
51 ================================= -->
52 <target name="load-ivy" depends="ident,ivy-taskdefs">
53 <ivy:settings file="${common.dir}/ivysettings.xml" />
54 </target>
55
56 <!-- =================================
57 target: ivy-taskdefs
58 ================================= -->
59 <target name="ivy-taskdefs" unless="ivy.loaded">
60 <property name="ivy.loaded" value="true"/>
61 <echo message="Loading Ivy ... common.dir=${common.dir}"/>
62
63 <taskdef resource="org/apache/ivy/ant/antlib.xml"
64 uri="antlib:org.apache.ivy.ant"
65 classpath="${ivy.jar}:${sigil-ivy-plugin.jar}"/>
66
67 <taskdef name="sigil.bundle"
68 classname="org.cauldron.bld.ant.BundleTask"
69 classpath="${sigil-ivy-plugin.jar}"/>
70
71 <taskdef name="sigil.bundle.info"
72 classname="org.cauldron.bld.ant.BundleInfoTask"
73 classpath="${sigil-ivy-plugin.jar}"/>
74 </target>
75
76
77 <!-- =================================
78 target: build (default target)
79 ================================= -->
80 <target name="build" depends="publish-local, composites" />
81
82 <target name="ident">
83 <echo message="${ant.project.name}"/>
84 </target>
85
86 <!-- =================================
87 target: resolve
88 ================================= -->
89 <target name="resolve" depends="load-ivy"
90 description="--> resolve and retrieve dependencies with ivy">
91 <mkdir dir="${deps.dir}"/>
92 <ivy:resolve file="${ivy.file}" log="${resolve.log}"/>
93 <ivy:retrieve pattern="${deps.dir}/[artifact].[ext]"
94 symlink="true" sync="true"/>
95 <!-- sync=true removes empty deps dir, so re-create it -->
96 <mkdir dir="${deps.dir}"/>
97 </target>
98
99 <!-- =================================
100 target: publish-local
101 ================================= -->
102
103 <target name="publish-check" unless="bundle.modified">
104 <ivy:info file="${ivy.file}"/>
105 <condition property="bundle.modified">
106 <not>
107 <available file="${repository.dir}/local/${ivy.module}" type="dir"/>
108 </not>
109 </condition>
110 </target>
111
112 <target name="publish-local" depends="bundle, publish-check" if="bundle.modified"
113 description="--> publish project in the local repository">
114
115 <tstamp>
116 <format property="now" pattern="yyyyMMddHHmmss"/>
117 </tstamp>
118 <property name="local-version" value="${now}"/>
119
120 <antcall target="clean-local"/>
121 <ivy:publish artifactspattern="${build.lib.dir}/[artifact].[ext]"
122 resolver="local"
123 pubrevision="${local-version}"
124 pubdate="${now}"
125 forcedeliver="true"
126 status="integration"/>
127 <echo message="project ${ant.project.name} published locally with version ${local-version}" />
128 </target>
129
130 <!-- =================================
131 target: report
132 ================================= -->
133 <target name="report" depends="resolve"
134 description="--> generates a report of dependencies">
135 <ivy:report todir="${build.dir}"/>
136 </target>
137
138 <!-- =================================
139 target: compile
140 ================================= -->
141 <target name="compile" depends="resolve"
142 description="--> compile the project">
143 <!-- uncomment the following to debug classpath -->
David Morgan Spenser Savage3b1b8c82009-07-20 21:01:49 +0000144 <pathconvert property="cp" refid="javac.classpath"/>
145 <echo>Classpath - ${cp}</echo>
Richard S. Hall6fe36b42009-07-13 13:25:46 +0000146 <mkdir dir="${classes.dir}" />
147 <javac srcdir="${src.dir}"
148 destdir="${classes.dir}"
149 classpathref="javac.classpath"
150 target="1.5"
151 debug="true" />
152 </target>
153
154 <!-- =================================
155 target: bundle
156 ================================= -->
157 <target name="bundle" depends="compile"
158 description="--> build OSGi bundle(s) for this project">
159 <mkdir dir="${build.lib.dir}"/>
160 <sigil.bundle
161 classpathref="sigil.classpath"
162 destpattern="${build.lib.dir}/[name].[ext]"
163 force="${bundle.force}"
164 property="bundle.modified" />
165 </target>
166
167 <!-- =================================
168 target: composites
169 ================================= -->
170 <available file="${composite.dir}" type="dir"
171 property="composite.dir.present"/>
172
173 <target name="composites" if="composite.dir.present"
174 description="--> filter xml composites replacing ${VERSION} etc.">
175 <mkdir dir="${build.etc.dir}"/>
176 <copy todir="${build.etc.dir}">
177 <fileset dir="${composite.dir}">
178 <exclude name="*-template.composite"/>
179 <include name="*.composite"/>
180 <include name="*.system"/>
181 </fileset>
182 <filterset begintoken="@" endtoken="@">
183 <filter token="VERSION" value="${bundle.version}"/>
184 <filter token="COMMUNITY_VERSION" value="${community.version}"/>
185 <filter token="JINI_VERSION" value="${jini.version}"/>
186 <filter token="PAREMUS_VERSION" value="${paremus.version}"/>
187 </filterset>
188 </copy>
189 </target>
190
191 <!-- =================================
192 target: install
193 install-bin, install-etc deprecated in favour of single
194 assemble/bin, assemble/etc dirs
195 ================================= -->
196 <target name="install"
197 depends="install-lib, install-composites"/>
198
199 <available file="bin" type="dir"
200 property="bin.dir.present"/>
201 <available file="etc" type="dir"
202 property="etc.dir.present"/>
203
204 <target name="install-bin" if="bin.dir.present">
205 <mkdir dir="${install.dir}/bin"/>
206 <copy todir="${install.dir}/bin">
207 <fileset dir="bin" />
208 </copy>
209 <chmod dir="${install.dir}/bin" perm="755" excludes="*.bat"/>
210 </target>
211
212 <target name="install-etc" if="etc.dir.present">
213 <mkdir dir="${install.dir}/etc"/>
214 <copy todir="${install.dir}/etc">
215 <fileset dir="etc" />
216 </copy>
217 </target>
218
219 <target name="composites-available">
220 <available file="${build.etc.dir}" type="dir"
221 property="build.etc.dir.present"/>
222 </target>
223
224 <target name="install-composites"
225 depends="composites, composites-available"
226 if="build.etc.dir.present">
227 <copy todir="${install.dir}/etc">
228 <fileset dir="${build.etc.dir}" />
229 </copy>
230 </target>
231
232 <target name="libs-available">
233 <available file="${build.lib.dir}" type="dir"
234 property="build.lib.dir.present"/>
235 </target>
236
237 <target name="install-lib"
238 depends="publish-local, libs-available"
239 if="build.lib.dir.present">
240 <copy todir="${install.dir}/lib">
241 <fileset dir="${build.lib.dir}" />
242 <mapper type="glob" from="*.jar" to="*-${buildVersion}.jar"/>
243 </copy>
244 </target>
245
246 <!-- =================================
247 target: clean-local
248 ================================= -->
249 <target name="clean-local" depends="load-ivy"
250 description="--> cleans the local repository for the current module">
251 <ivy:info file="${ivy.file}"/>
252 <delete dir="${repository.dir}/local/${ivy.module}"/>
253 </target>
254
255 <!-- =================================
256 target: clean-deps
257 ================================= -->
258 <target name="clean-deps"
259 description="--> clean the project dependencies directory">
260 <delete includeemptydirs="true" dir="${deps.dir}"/>
261 </target>
262
263 <!-- =================================
264 target: clean-build
265 ================================= -->
266 <target name="clean-build"
267 description="--> clean the project built files">
268 <delete includeemptydirs="true" dir="${build.dir}"/>
269 </target>
270
271 <!-- =================================
272 target: clean
273 ================================= -->
274 <target name="clean" depends="ident, clean-build, clean-deps"
275 description="--> clean the project" />
276
277
278 <!-- =================================
279 target: buildlist
280 ================================= -->
281 <target name="buildlist" depends="load-ivy">
282 <ivy:buildlist reference="ordered-list"
283 onMissingDescriptor="skip">
284 <fileset refid="my.projects"/>
285 </ivy:buildlist>
286 </target>
287
288 <!-- =================================
289 target: build-list
290 ================================= -->
291 <target name="build-list" depends="buildlist"
292 description="--> build all projects in the right order">
293 <property name="target" value="build"/>
294 <subant target="${target}" buildpathref="ordered-list">
295 <propertyset>
296 <propertyref name="ivy.loaded" />
297 </propertyset>
298 </subant>
299 </target>
300
301 <!-- =================================
302 target: install-list
303 ================================= -->
304 <target name="install-list"
305 description="--> install all projects">
306 <antcall target="build-list">
307 <param name="target" value="install"/>
308 </antcall>
309 </target>
310
311 <!-- =================================
312 target: ident-list
313 ================================= -->
314 <target name="ident-list"
315 description="--> identify projects">
316 <antcall target="build-list">
317 <param name="target" value="ident"/>
318 </antcall>
319 </target>
320
321 <!-- =================================
322 target: clean-list
323 ================================= -->
324 <target name="clean-list"
325 description="--> clean all projects">
326 <antcall target="build-list">
327 <param name="target" value="clean"/>
328 </antcall>
329 </target>
330
331 <!-- =================================
332 target: clean-all
333 ================================= -->
334 <target name="clean-all" depends="clean-list, clean"
335 description="--> clean repository, cache, and all projects">
336 <delete dir="${repository.dir}"/>
337 <delete dir="${cache.dir}"/>
338 <delete dir="${install.dir}"/>
339 <delete dir="${dist.dir}"/>
340 </target>
341
342 <target name="sigil.test" depends="ivy-taskdefs">
343 <mkdir dir="${dist.dir}/lib/sigil" />
344 <copy todir="${dist.dir}/lib/sigil" overwrite="true">
345 <fileset dir="${common.dir}/test/lib">
346 <include name="*.jar" />
347 </fileset>
348 </copy>
349
350 <mkdir dir="${dist.dir}/etc/sigil/boot" />
351
352 <copy todir="${dist.dir}/etc/sigil/boot" overwrite="true">
353 <fileset dir="${common.dir}/test/etc/boot">
354 <include name="*" />
355 </fileset>
356 </copy>
357
358 <property name="install.script" value="${dist.dir}/etc/sigil/boot/2-install-tests" />
359 <delete file="${install.script}" />
360
361 <for param="project">
362 <fileset refid="my.projects" />
363 <sequential>
364 <antcall target="sigil.test.setup">
365 <param name="project" value="@{project}"/>
366 </antcall>
367 </sequential>
368 </for>
369
370 <for param="project">
371 <fileset refid="my.projects" />
372 <sequential>
373 <antcall target="sigil.test.install">
374 <param name="project" value="@{project}"/>
375 </antcall>
376 </sequential>
377 </for>
378
379 <delete dir="${dist.dir}/../test-results" />
380
381 <exec executable="sh" osfamily="unix">
382 <arg line="${dist.dir}/bin/container equinox -verbose=true" />
383 <arg line="-bootScript=etc/sigil/boot" />
384 </exec>
385 </target>
386
387 <target name="sigil.test.setup">
388 <property name="dir" location="${project}/../" />
389 <path id="test.resources">
390 <fileset dir="${dir}">
391 <include name="build/lib/*.jar" />
392 <exclude name="**/*-dl.jar" />
393 </fileset>
394 <fileset dir="${dir}">
395 <include name="build/deps/*.jar" />
396 <exclude name="**/*!*.jar" />
397 </fileset>
398 </path>
399 <for param="jar">
400 <path refid="test.resources"/>
401 <sequential>
402 <antcall target="sigil.test.load">
403 <param name="jar" value="@{jar}" />
404 </antcall>
405 </sequential>
406 </for>
407 </target>
408
409 <target name="sigil.test.install">
410 <property name="dir" location="${project}/../" />
411 <path id="test.bundles">
412 <fileset dir="${dir}">
413 <include name="build/lib/*test.jar" />
414 </fileset>
415 </path>
416 <for param="jar">
417 <path refid="test.bundles"/>
418 <sequential>
419 <antcall target="sigil.test.start">
420 <param name="jar" value="@{jar}" />
421 </antcall>
422 </sequential>
423 </for>
424 </target>
425
426 <target name="sigil.test.load">
427 <sigil.bundle.info bundle="${jar}" header="Bundle-SymbolicName" property="test.bundle.symbolic.name"/>
428 <if>
429 <isset property="test.bundle.symbolic.name"/>
430 <then>
431 <echo file="${install.script}" append="true">cds load boot ${test.bundle.symbolic.name}.jar ${jar}
432</echo>
433 </then>
434 </if>
435 </target>
436
437 <target name="sigil.test.start">
438 <sigil.bundle.info bundle="${jar}" header="Bundle-SymbolicName" property="test.bundle.symbolic.name"/>
439 <if>
440 <isset property="test.bundle.symbolic.name"/>
441 <then>
442 <sigil.bundle.info bundle="${jar}" header="Bundle-Version" property="test.bundle.version" defaultvalue="0"/>
443 <sigil.bundle.info bundle="${jar}" header="Fragment-Host" property="test.bundle.fragment"/>
444 <if>
445 <isset property="test.bundle.fragment" />
446 <then>
447 <propertyregex property="test.bundle.fragment.name"
448 input="${test.bundle.fragment}"
449 regexp="([^;]*).*"
450 select="\1"
451 casesensitive="false" />
452
453 <echo file="${install.script}" append="true">nim policy -a osgi.installed.bundle/${test.bundle.fragment.name} osgi.fragment.bundle/${test.bundle.symbolic.name}:${test.bundle.version}
454</echo>
455 <echo file="${install.script}" append="true">nim add ${test.bundle.symbolic.name}:${test.bundle.version}@fragment
456</echo>
457 </then>
458 <else>
459 <echo file="${install.script}" append="true">nim add ${test.bundle.symbolic.name}:${test.bundle.version}@installed
460</echo>
461 </else>
462 </if>
463 </then>
464 </if>
465 </target>
466</project>