blob: 670338529b259eee2a1255c10bd77597249fe739 [file] [log] [blame]
Richard S. Hall85bafab2009-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 Spencer Savagef977a8d2009-07-20 21:01:49 +000020<project name="bldcommon"
Richard S. Hall85bafab2009-07-13 13:25:46 +000021 xmlns:ivy="antlib:org.apache.ivy.ant">
22
David Morgan Spencer Savagef977a8d2009-07-20 21:01:49 +000023 <dirname property="common.dir" file="${ant.file.bldcommon}"/>
Richard S. Hall85bafab2009-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"
David Morgan Spencer Savageb0f8ac72009-07-21 20:42:53 +000068 classname="org.apache.felix.sigil.ant.BundleTask"
Richard S. Hall85bafab2009-07-13 13:25:46 +000069 classpath="${sigil-ivy-plugin.jar}"/>
70
71 <taskdef name="sigil.bundle.info"
David Morgan Spencer Savageb0f8ac72009-07-21 20:42:53 +000072 classname="org.apache.felix.sigil.ant.BundleInfoTask"
Richard S. Hall85bafab2009-07-13 13:25:46 +000073 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 ================================= -->
David Morgan Spencer Savage014e5372009-07-22 19:15:19 +000089 <target name="resolve" depends="common-init"
Richard S. Hall85bafab2009-07-13 13:25:46 +000090 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 Spencer Savageb0f8ac72009-07-21 20:42:53 +0000144 <!--pathconvert property="cp" refid="javac.classpath"/>
145 <echo>Classpath - ${cp}</echo-->
Richard S. Hall85bafab2009-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 <!-- =================================
David Morgan Spencer Savage014e5372009-07-22 19:15:19 +0000279 target: common-init
280 ================================= -->
281 <target name="common-init" depends="load-ivy,init">
282 </target>
283
284 <!-- =================================
285 target: init
286 ================================= -->
287 <target name="init">
288 </target>
289
290 <!-- =================================
Richard S. Hall85bafab2009-07-13 13:25:46 +0000291 target: buildlist
292 ================================= -->
David Morgan Spencer Savage014e5372009-07-22 19:15:19 +0000293 <target name="buildlist" depends="common-init">
Richard S. Hall85bafab2009-07-13 13:25:46 +0000294 <ivy:buildlist reference="ordered-list"
295 onMissingDescriptor="skip">
296 <fileset refid="my.projects"/>
297 </ivy:buildlist>
298 </target>
299
300 <!-- =================================
301 target: build-list
302 ================================= -->
303 <target name="build-list" depends="buildlist"
304 description="--> build all projects in the right order">
305 <property name="target" value="build"/>
306 <subant target="${target}" buildpathref="ordered-list">
307 <propertyset>
308 <propertyref name="ivy.loaded" />
309 </propertyset>
310 </subant>
311 </target>
312
313 <!-- =================================
314 target: install-list
315 ================================= -->
316 <target name="install-list"
317 description="--> install all projects">
318 <antcall target="build-list">
319 <param name="target" value="install"/>
320 </antcall>
321 </target>
322
323 <!-- =================================
324 target: ident-list
325 ================================= -->
326 <target name="ident-list"
327 description="--> identify projects">
328 <antcall target="build-list">
329 <param name="target" value="ident"/>
330 </antcall>
331 </target>
332
333 <!-- =================================
334 target: clean-list
335 ================================= -->
336 <target name="clean-list"
337 description="--> clean all projects">
338 <antcall target="build-list">
339 <param name="target" value="clean"/>
340 </antcall>
341 </target>
342
343 <!-- =================================
344 target: clean-all
345 ================================= -->
346 <target name="clean-all" depends="clean-list, clean"
347 description="--> clean repository, cache, and all projects">
348 <delete dir="${repository.dir}"/>
349 <delete dir="${cache.dir}"/>
350 <delete dir="${install.dir}"/>
351 <delete dir="${dist.dir}"/>
352 </target>
353
354 <target name="sigil.test" depends="ivy-taskdefs">
355 <mkdir dir="${dist.dir}/lib/sigil" />
356 <copy todir="${dist.dir}/lib/sigil" overwrite="true">
357 <fileset dir="${common.dir}/test/lib">
358 <include name="*.jar" />
359 </fileset>
360 </copy>
361
362 <mkdir dir="${dist.dir}/etc/sigil/boot" />
363
364 <copy todir="${dist.dir}/etc/sigil/boot" overwrite="true">
365 <fileset dir="${common.dir}/test/etc/boot">
366 <include name="*" />
367 </fileset>
368 </copy>
369
370 <property name="install.script" value="${dist.dir}/etc/sigil/boot/2-install-tests" />
371 <delete file="${install.script}" />
372
373 <for param="project">
374 <fileset refid="my.projects" />
375 <sequential>
376 <antcall target="sigil.test.setup">
377 <param name="project" value="@{project}"/>
378 </antcall>
379 </sequential>
380 </for>
381
382 <for param="project">
383 <fileset refid="my.projects" />
384 <sequential>
385 <antcall target="sigil.test.install">
386 <param name="project" value="@{project}"/>
387 </antcall>
388 </sequential>
389 </for>
390
391 <delete dir="${dist.dir}/../test-results" />
392
393 <exec executable="sh" osfamily="unix">
394 <arg line="${dist.dir}/bin/container equinox -verbose=true" />
395 <arg line="-bootScript=etc/sigil/boot" />
396 </exec>
397 </target>
398
399 <target name="sigil.test.setup">
400 <property name="dir" location="${project}/../" />
401 <path id="test.resources">
402 <fileset dir="${dir}">
403 <include name="build/lib/*.jar" />
404 <exclude name="**/*-dl.jar" />
405 </fileset>
406 <fileset dir="${dir}">
407 <include name="build/deps/*.jar" />
408 <exclude name="**/*!*.jar" />
409 </fileset>
410 </path>
411 <for param="jar">
412 <path refid="test.resources"/>
413 <sequential>
414 <antcall target="sigil.test.load">
415 <param name="jar" value="@{jar}" />
416 </antcall>
417 </sequential>
418 </for>
419 </target>
420
421 <target name="sigil.test.install">
422 <property name="dir" location="${project}/../" />
423 <path id="test.bundles">
424 <fileset dir="${dir}">
425 <include name="build/lib/*test.jar" />
426 </fileset>
427 </path>
428 <for param="jar">
429 <path refid="test.bundles"/>
430 <sequential>
431 <antcall target="sigil.test.start">
432 <param name="jar" value="@{jar}" />
433 </antcall>
434 </sequential>
435 </for>
436 </target>
437
438 <target name="sigil.test.load">
439 <sigil.bundle.info bundle="${jar}" header="Bundle-SymbolicName" property="test.bundle.symbolic.name"/>
440 <if>
441 <isset property="test.bundle.symbolic.name"/>
442 <then>
443 <echo file="${install.script}" append="true">cds load boot ${test.bundle.symbolic.name}.jar ${jar}
444</echo>
445 </then>
446 </if>
447 </target>
448
449 <target name="sigil.test.start">
450 <sigil.bundle.info bundle="${jar}" header="Bundle-SymbolicName" property="test.bundle.symbolic.name"/>
451 <if>
452 <isset property="test.bundle.symbolic.name"/>
453 <then>
454 <sigil.bundle.info bundle="${jar}" header="Bundle-Version" property="test.bundle.version" defaultvalue="0"/>
455 <sigil.bundle.info bundle="${jar}" header="Fragment-Host" property="test.bundle.fragment"/>
456 <if>
457 <isset property="test.bundle.fragment" />
458 <then>
459 <propertyregex property="test.bundle.fragment.name"
460 input="${test.bundle.fragment}"
461 regexp="([^;]*).*"
462 select="\1"
463 casesensitive="false" />
464
465 <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}
466</echo>
467 <echo file="${install.script}" append="true">nim add ${test.bundle.symbolic.name}:${test.bundle.version}@fragment
468</echo>
469 </then>
470 <else>
471 <echo file="${install.script}" append="true">nim add ${test.bundle.symbolic.name}:${test.bundle.version}@installed
472</echo>
473 </else>
474 </if>
475 </then>
476 </if>
477 </target>
478</project>