blob: cfe350886ae9b8eb968f0585dbf91c14d710d42c [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 ================================= -->
David Morgan Spenser Savagea4fbd5b2009-07-23 13:16:00 +000052 <target name="load-ivy" depends="init-sigil">
53 <echo message="Loading Ivy ... common.dir=${common.dir}"/>
Richard S. Hall6fe36b42009-07-13 13:25:46 +000054 <ivy:settings file="${common.dir}/ivysettings.xml" />
55 </target>
56
57 <!-- =================================
Richard S. Hall6fe36b42009-07-13 13:25:46 +000058 target: build (default target)
59 ================================= -->
David Morgan Spenser Savageef091e22009-09-11 20:50:48 +000060 <target name="build" depends="publish-local" />
Richard S. Hall6fe36b42009-07-13 13:25:46 +000061
62 <target name="ident">
63 <echo message="${ant.project.name}"/>
64 </target>
65
66 <!-- =================================
67 target: resolve
68 ================================= -->
David Morgan Spenser Savage7478b7b2009-07-22 19:15:19 +000069 <target name="resolve" depends="common-init"
Richard S. Hall6fe36b42009-07-13 13:25:46 +000070 description="--> resolve and retrieve dependencies with ivy">
71 <mkdir dir="${deps.dir}"/>
72 <ivy:resolve file="${ivy.file}" log="${resolve.log}"/>
73 <ivy:retrieve pattern="${deps.dir}/[artifact].[ext]"
74 symlink="true" sync="true"/>
75 <!-- sync=true removes empty deps dir, so re-create it -->
76 <mkdir dir="${deps.dir}"/>
77 </target>
78
79 <!-- =================================
80 target: publish-local
81 ================================= -->
82
83 <target name="publish-check" unless="bundle.modified">
84 <ivy:info file="${ivy.file}"/>
85 <condition property="bundle.modified">
86 <not>
87 <available file="${repository.dir}/local/${ivy.module}" type="dir"/>
88 </not>
89 </condition>
90 </target>
91
92 <target name="publish-local" depends="bundle, publish-check" if="bundle.modified"
93 description="--> publish project in the local repository">
94
95 <tstamp>
96 <format property="now" pattern="yyyyMMddHHmmss"/>
97 </tstamp>
98 <property name="local-version" value="${now}"/>
99
100 <antcall target="clean-local"/>
101 <ivy:publish artifactspattern="${build.lib.dir}/[artifact].[ext]"
102 resolver="local"
103 pubrevision="${local-version}"
104 pubdate="${now}"
105 forcedeliver="true"
106 status="integration"/>
107 <echo message="project ${ant.project.name} published locally with version ${local-version}" />
108 </target>
109
110 <!-- =================================
111 target: report
112 ================================= -->
113 <target name="report" depends="resolve"
114 description="--> generates a report of dependencies">
115 <ivy:report todir="${build.dir}"/>
116 </target>
117
118 <!-- =================================
119 target: compile
120 ================================= -->
121 <target name="compile" depends="resolve"
122 description="--> compile the project">
123 <!-- uncomment the following to debug classpath -->
David Morgan Spenser Savage2c182412009-07-21 20:42:53 +0000124 <!--pathconvert property="cp" refid="javac.classpath"/>
125 <echo>Classpath - ${cp}</echo-->
Richard S. Hall6fe36b42009-07-13 13:25:46 +0000126 <mkdir dir="${classes.dir}" />
127 <javac srcdir="${src.dir}"
128 destdir="${classes.dir}"
129 classpathref="javac.classpath"
130 target="1.5"
131 debug="true" />
132 </target>
133
134 <!-- =================================
135 target: bundle
136 ================================= -->
137 <target name="bundle" depends="compile"
138 description="--> build OSGi bundle(s) for this project">
139 <mkdir dir="${build.lib.dir}"/>
140 <sigil.bundle
141 classpathref="sigil.classpath"
142 destpattern="${build.lib.dir}/[name].[ext]"
143 force="${bundle.force}"
144 property="bundle.modified" />
145 </target>
146
147 <!-- =================================
Richard S. Hall6fe36b42009-07-13 13:25:46 +0000148 target: install
149 install-bin, install-etc deprecated in favour of single
150 assemble/bin, assemble/etc dirs
151 ================================= -->
152 <target name="install"
David Morgan Spenser Savageef091e22009-09-11 20:50:48 +0000153 depends="install-lib"/>
Richard S. Hall6fe36b42009-07-13 13:25:46 +0000154
155 <available file="bin" type="dir"
156 property="bin.dir.present"/>
157 <available file="etc" type="dir"
158 property="etc.dir.present"/>
159
160 <target name="install-bin" if="bin.dir.present">
161 <mkdir dir="${install.dir}/bin"/>
162 <copy todir="${install.dir}/bin">
163 <fileset dir="bin" />
164 </copy>
165 <chmod dir="${install.dir}/bin" perm="755" excludes="*.bat"/>
166 </target>
167
168 <target name="install-etc" if="etc.dir.present">
169 <mkdir dir="${install.dir}/etc"/>
170 <copy todir="${install.dir}/etc">
171 <fileset dir="etc" />
172 </copy>
173 </target>
174
Richard S. Hall6fe36b42009-07-13 13:25:46 +0000175 <target name="libs-available">
176 <available file="${build.lib.dir}" type="dir"
177 property="build.lib.dir.present"/>
178 </target>
179
180 <target name="install-lib"
181 depends="publish-local, libs-available"
182 if="build.lib.dir.present">
183 <copy todir="${install.dir}/lib">
184 <fileset dir="${build.lib.dir}" />
185 <mapper type="glob" from="*.jar" to="*-${buildVersion}.jar"/>
186 </copy>
187 </target>
188
189 <!-- =================================
190 target: clean-local
191 ================================= -->
David Morgan Spenser Savagea4fbd5b2009-07-23 13:16:00 +0000192 <target name="clean-local" depends="boot"
Richard S. Hall6fe36b42009-07-13 13:25:46 +0000193 description="--> cleans the local repository for the current module">
194 <ivy:info file="${ivy.file}"/>
195 <delete dir="${repository.dir}/local/${ivy.module}"/>
196 </target>
197
198 <!-- =================================
199 target: clean-deps
200 ================================= -->
201 <target name="clean-deps"
202 description="--> clean the project dependencies directory">
203 <delete includeemptydirs="true" dir="${deps.dir}"/>
204 </target>
205
206 <!-- =================================
207 target: clean-build
208 ================================= -->
209 <target name="clean-build"
210 description="--> clean the project built files">
211 <delete includeemptydirs="true" dir="${build.dir}"/>
212 </target>
213
214 <!-- =================================
215 target: clean
216 ================================= -->
217 <target name="clean" depends="ident, clean-build, clean-deps"
218 description="--> clean the project" />
219
220
221 <!-- =================================
David Morgan Spenser Savagea4fbd5b2009-07-23 13:16:00 +0000222 target: boot
223 ================================= -->
224 <target name="boot" depends="load-ivy">
225 </target>
226
227 <!-- =================================
David Morgan Spenser Savage7478b7b2009-07-22 19:15:19 +0000228 target: common-init
229 ================================= -->
David Morgan Spenser Savagea4fbd5b2009-07-23 13:16:00 +0000230 <target name="common-init" depends="ident,boot,init">
David Morgan Spenser Savage7478b7b2009-07-22 19:15:19 +0000231 </target>
232
233 <!-- =================================
234 target: init
235 ================================= -->
236 <target name="init">
237 </target>
238
239 <!-- =================================
Richard S. Hall6fe36b42009-07-13 13:25:46 +0000240 target: buildlist
241 ================================= -->
David Morgan Spenser Savage7478b7b2009-07-22 19:15:19 +0000242 <target name="buildlist" depends="common-init">
Richard S. Hall6fe36b42009-07-13 13:25:46 +0000243 <ivy:buildlist reference="ordered-list"
244 onMissingDescriptor="skip">
245 <fileset refid="my.projects"/>
246 </ivy:buildlist>
247 </target>
248
249 <!-- =================================
250 target: build-list
251 ================================= -->
252 <target name="build-list" depends="buildlist"
253 description="--> build all projects in the right order">
254 <property name="target" value="build"/>
255 <subant target="${target}" buildpathref="ordered-list">
256 <propertyset>
257 <propertyref name="ivy.loaded" />
258 </propertyset>
259 </subant>
260 </target>
261
262 <!-- =================================
David Morgan Spenser Savageef091e22009-09-11 20:50:48 +0000263 target: report-list
264 ================================= -->
265 <target name="report-list"
266 description="--> report all projects">
267 <antcall target="build-list">
268 <param name="target" value="report"/>
269 </antcall>
270 </target>
271
272 <!-- =================================
Richard S. Hall6fe36b42009-07-13 13:25:46 +0000273 target: install-list
274 ================================= -->
275 <target name="install-list"
276 description="--> install all projects">
277 <antcall target="build-list">
278 <param name="target" value="install"/>
279 </antcall>
280 </target>
281
282 <!-- =================================
283 target: ident-list
284 ================================= -->
285 <target name="ident-list"
286 description="--> identify projects">
287 <antcall target="build-list">
288 <param name="target" value="ident"/>
289 </antcall>
290 </target>
291
292 <!-- =================================
293 target: clean-list
294 ================================= -->
295 <target name="clean-list"
296 description="--> clean all projects">
297 <antcall target="build-list">
298 <param name="target" value="clean"/>
299 </antcall>
300 </target>
301
302 <!-- =================================
303 target: clean-all
304 ================================= -->
305 <target name="clean-all" depends="clean-list, clean"
306 description="--> clean repository, cache, and all projects">
307 <delete dir="${repository.dir}"/>
308 <delete dir="${cache.dir}"/>
309 <delete dir="${install.dir}"/>
310 <delete dir="${dist.dir}"/>
311 </target>
David Morgan Spenser Savagea4fbd5b2009-07-23 13:16:00 +0000312
313 <condition property="ivy.home" value="${env.SIGIL_HOME}">
314 <isset property="env.SIGIL_HOME" />
315 </condition>
316
David Morgan Spenser Savagef3f70c22009-07-23 15:23:30 +0000317 <property name="sigil.home" value="${common.dir}/../cache/ant" />
David Morgan Spenser Savagea4fbd5b2009-07-23 13:16:00 +0000318 <property name="sigil.jar.dir" value="${sigil.home}/lib" />
319 <property name="ivy.jar.file" value="${sigil.jar.dir}/ivy.jar" />
320 <property name="sigil.jar.file" value="${sigil.jar.dir}/sigil-ivy-plugin.jar" />
321 <property name="bnd.jar.file" value="${sigil.jar.dir}/bndlib.jar" />
322 <property name="equinox.common.jar.file" value="${sigil.jar.dir}/equinox.common.jar" />
323
324
325 <target name="download-deps" unless="offline">
326 <property name="deps.loaded" value="true"/>
327 <mkdir dir="${sigil.jar.dir}"/>
328 <!-- ivy -->
329 <get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
330 dest="${ivy.jar.file}" usetimestamp="true" verbose="true"/>
331 <!-- sigil -->
332 <get src="http://people.apache.org/~dsavage/sigil/sigil-ivy-plugin.jar"
333 dest="${sigil.jar.file}" usetimestamp="true" verbose="true"/>
334 <!-- bnd -->
335 <get src="http://www.aQute.biz/repo/biz/aQute/bndlib/${bnd.install.version}/bndlib-${bnd.install.version}.jar"
336 dest="${bnd.jar.file}" usetimestamp="true" verbose="true"/>
337 <!-- equinox.common -->
338 <get src=" http://download.eclipse.org/releases/${equinox.release}/plugins/org.eclipse.equinox.common_${equinox.install.version}.jar"
339 dest="${equinox.common.jar.file}" usetimestamp="true" verbose="true"/>
340 </target>
341
342 <target name="check-sigil">
343 <condition property="sigil.loaded">
344 <typefound name="sigil.bundle" />
345 </condition>
346 </target>
347
348 <target name="init-sigil" depends="check-sigil" unless="sigil.loaded">
349 <antcall target="download-deps" />
350 <!-- try to load ivy here from ivy home, in case the user has not already dropped
351 it into ant's lib dir (note that the latter copy will always take precedence).
352 We will not fail as long as local lib dir exists (it may be empty) and
353 ivy is in at least one of ant's lib dir or the local lib dir. -->
354 <path id="sigil.lib.path">
355 <fileset dir="${sigil.jar.dir}" includes="*.jar"/>
356 </path>
357
358 <echo>Initialising sigil with ${sigil.jar.dir}</echo>
359
360 <taskdef resource="org/apache/ivy/ant/antlib.xml"
361 uri="antlib:org.apache.ivy.ant" classpathref="sigil.lib.path"/>
362
363 <taskdef name="sigil.bundle"
364 classname="org.apache.felix.sigil.ant.BundleTask" classpathref="sigil.lib.path"/>
365
366 <taskdef name="sigil.bundle.info"
367 classname="org.apache.felix.sigil.ant.BundleInfoTask" classpathref="sigil.lib.path"/>
368 </target>
Richard S. Hall6fe36b42009-07-13 13:25:46 +0000369
Richard S. Hall6fe36b42009-07-13 13:25:46 +0000370</project>