blob: f26093335321c2945cf9674b1e7df0ed71a27a70 [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"
David Morgan Spenser Savage0f102f92009-09-18 15:45:19 +000021 xmlns:ivy="antlib:org.apache.ivy.ant"
22 xmlns:groovy="antlib:org.codehaus.groovy">
Richard S. Hall6fe36b42009-07-13 13:25:46 +000023
David Morgan Spenser Savage3b1b8c82009-07-20 21:01:49 +000024 <dirname property="common.dir" file="${ant.file.bldcommon}"/>
Richard S. Hall6fe36b42009-07-13 13:25:46 +000025 <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">
David Morgan Spenser Savage0f102f92009-09-18 15:45:19 +000053 <echo message="Loading Ivy ... ${common.dir}/ivysettings.xml"/>
Richard S. Hall6fe36b42009-07-13 13:25:46 +000054 <ivy:settings file="${common.dir}/ivysettings.xml" />
55 </target>
56
David Morgan Spenser Savage0f102f92009-09-18 15:45:19 +000057 <target name="load-groovy">
58 <ivy:cachepath
59 organisation="org.codehaus.groovy"
60 module="groovy-all"
61 revision="1.6.4"
62 inline="true"
63 pathid="groovy.classpath"
64 transitive="false"
65 log="quiet"/>
66
67 <taskdef resource="org/codehaus/groovy/antlib.xml"
68 uri="antlib:org.codehaus.groovy" classpathref="groovy.classpath"/>
69 </target>
70
Richard S. Hall6fe36b42009-07-13 13:25:46 +000071 <!-- =================================
Richard S. Hall6fe36b42009-07-13 13:25:46 +000072 target: build (default target)
73 ================================= -->
David Morgan Spenser Savageef091e22009-09-11 20:50:48 +000074 <target name="build" depends="publish-local" />
Richard S. Hall6fe36b42009-07-13 13:25:46 +000075
76 <target name="ident">
77 <echo message="${ant.project.name}"/>
78 </target>
79
80 <!-- =================================
81 target: resolve
82 ================================= -->
David Morgan Spenser Savage7478b7b2009-07-22 19:15:19 +000083 <target name="resolve" depends="common-init"
Richard S. Hall6fe36b42009-07-13 13:25:46 +000084 description="--> resolve and retrieve dependencies with ivy">
85 <mkdir dir="${deps.dir}"/>
86 <ivy:resolve file="${ivy.file}" log="${resolve.log}"/>
87 <ivy:retrieve pattern="${deps.dir}/[artifact].[ext]"
88 symlink="true" sync="true"/>
89 <!-- sync=true removes empty deps dir, so re-create it -->
90 <mkdir dir="${deps.dir}"/>
91 </target>
92
93 <!-- =================================
94 target: publish-local
95 ================================= -->
96
97 <target name="publish-check" unless="bundle.modified">
98 <ivy:info file="${ivy.file}"/>
99 <condition property="bundle.modified">
100 <not>
101 <available file="${repository.dir}/local/${ivy.module}" type="dir"/>
102 </not>
103 </condition>
104 </target>
105
106 <target name="publish-local" depends="bundle, publish-check" if="bundle.modified"
107 description="--> publish project in the local repository">
108
109 <tstamp>
110 <format property="now" pattern="yyyyMMddHHmmss"/>
111 </tstamp>
112 <property name="local-version" value="${now}"/>
113
114 <antcall target="clean-local"/>
115 <ivy:publish artifactspattern="${build.lib.dir}/[artifact].[ext]"
116 resolver="local"
117 pubrevision="${local-version}"
118 pubdate="${now}"
119 forcedeliver="true"
120 status="integration"/>
121 <echo message="project ${ant.project.name} published locally with version ${local-version}" />
122 </target>
123
124 <!-- =================================
125 target: report
126 ================================= -->
127 <target name="report" depends="resolve"
128 description="--> generates a report of dependencies">
129 <ivy:report todir="${build.dir}"/>
130 </target>
131
132 <!-- =================================
133 target: compile
134 ================================= -->
135 <target name="compile" depends="resolve"
136 description="--> compile the project">
137 <!-- uncomment the following to debug classpath -->
David Morgan Spenser Savage2c182412009-07-21 20:42:53 +0000138 <!--pathconvert property="cp" refid="javac.classpath"/>
139 <echo>Classpath - ${cp}</echo-->
Richard S. Hall6fe36b42009-07-13 13:25:46 +0000140 <mkdir dir="${classes.dir}" />
141 <javac srcdir="${src.dir}"
142 destdir="${classes.dir}"
143 classpathref="javac.classpath"
144 target="1.5"
145 debug="true" />
146 </target>
147
148 <!-- =================================
149 target: bundle
150 ================================= -->
151 <target name="bundle" depends="compile"
152 description="--> build OSGi bundle(s) for this project">
153 <mkdir dir="${build.lib.dir}"/>
154 <sigil.bundle
155 classpathref="sigil.classpath"
156 destpattern="${build.lib.dir}/[name].[ext]"
157 force="${bundle.force}"
158 property="bundle.modified" />
159 </target>
160
Richard S. Hall6fe36b42009-07-13 13:25:46 +0000161 <available file="bin" type="dir"
162 property="bin.dir.present"/>
163 <available file="etc" type="dir"
164 property="etc.dir.present"/>
165
166 <target name="install-bin" if="bin.dir.present">
167 <mkdir dir="${install.dir}/bin"/>
168 <copy todir="${install.dir}/bin">
169 <fileset dir="bin" />
170 </copy>
171 <chmod dir="${install.dir}/bin" perm="755" excludes="*.bat"/>
172 </target>
173
174 <target name="install-etc" if="etc.dir.present">
175 <mkdir dir="${install.dir}/etc"/>
176 <copy todir="${install.dir}/etc">
177 <fileset dir="etc" />
178 </copy>
179 </target>
180
Richard S. Hall6fe36b42009-07-13 13:25:46 +0000181 <target name="libs-available">
182 <available file="${build.lib.dir}" type="dir"
183 property="build.lib.dir.present"/>
184 </target>
185
186 <target name="install-lib"
187 depends="publish-local, libs-available"
188 if="build.lib.dir.present">
189 <copy todir="${install.dir}/lib">
190 <fileset dir="${build.lib.dir}" />
191 <mapper type="glob" from="*.jar" to="*-${buildVersion}.jar"/>
192 </copy>
193 </target>
194
195 <!-- =================================
196 target: clean-local
197 ================================= -->
David Morgan Spenser Savagea4fbd5b2009-07-23 13:16:00 +0000198 <target name="clean-local" depends="boot"
Richard S. Hall6fe36b42009-07-13 13:25:46 +0000199 description="--> cleans the local repository for the current module">
200 <ivy:info file="${ivy.file}"/>
201 <delete dir="${repository.dir}/local/${ivy.module}"/>
202 </target>
203
204 <!-- =================================
205 target: clean-deps
206 ================================= -->
207 <target name="clean-deps"
208 description="--> clean the project dependencies directory">
209 <delete includeemptydirs="true" dir="${deps.dir}"/>
210 </target>
211
212 <!-- =================================
213 target: clean-build
214 ================================= -->
215 <target name="clean-build"
216 description="--> clean the project built files">
217 <delete includeemptydirs="true" dir="${build.dir}"/>
218 </target>
219
220 <!-- =================================
221 target: clean
222 ================================= -->
223 <target name="clean" depends="ident, clean-build, clean-deps"
224 description="--> clean the project" />
225
226
227 <!-- =================================
David Morgan Spenser Savagea4fbd5b2009-07-23 13:16:00 +0000228 target: boot
229 ================================= -->
David Morgan Spenser Savage0f102f92009-09-18 15:45:19 +0000230 <target name="boot" depends="load-ivy,load-groovy">
David Morgan Spenser Savagea4fbd5b2009-07-23 13:16:00 +0000231 </target>
232
233 <!-- =================================
David Morgan Spenser Savage7478b7b2009-07-22 19:15:19 +0000234 target: common-init
235 ================================= -->
David Morgan Spenser Savagea4fbd5b2009-07-23 13:16:00 +0000236 <target name="common-init" depends="ident,boot,init">
David Morgan Spenser Savage7478b7b2009-07-22 19:15:19 +0000237 </target>
238
239 <!-- =================================
240 target: init
241 ================================= -->
242 <target name="init">
243 </target>
244
245 <!-- =================================
Richard S. Hall6fe36b42009-07-13 13:25:46 +0000246 target: buildlist
247 ================================= -->
David Morgan Spenser Savage7478b7b2009-07-22 19:15:19 +0000248 <target name="buildlist" depends="common-init">
Richard S. Hall6fe36b42009-07-13 13:25:46 +0000249 <ivy:buildlist reference="ordered-list"
250 onMissingDescriptor="skip">
251 <fileset refid="my.projects"/>
252 </ivy:buildlist>
253 </target>
254
255 <!-- =================================
256 target: build-list
257 ================================= -->
258 <target name="build-list" depends="buildlist"
259 description="--> build all projects in the right order">
260 <property name="target" value="build"/>
261 <subant target="${target}" buildpathref="ordered-list">
262 <propertyset>
263 <propertyref name="ivy.loaded" />
264 </propertyset>
265 </subant>
266 </target>
267
268 <!-- =================================
David Morgan Spenser Savageef091e22009-09-11 20:50:48 +0000269 target: report-list
270 ================================= -->
271 <target name="report-list"
272 description="--> report all projects">
273 <antcall target="build-list">
274 <param name="target" value="report"/>
275 </antcall>
276 </target>
277
278 <!-- =================================
Richard S. Hall6fe36b42009-07-13 13:25:46 +0000279 target: install-list
280 ================================= -->
281 <target name="install-list"
282 description="--> install all projects">
283 <antcall target="build-list">
284 <param name="target" value="install"/>
285 </antcall>
286 </target>
287
288 <!-- =================================
289 target: ident-list
290 ================================= -->
291 <target name="ident-list"
292 description="--> identify projects">
293 <antcall target="build-list">
294 <param name="target" value="ident"/>
295 </antcall>
296 </target>
297
298 <!-- =================================
299 target: clean-list
300 ================================= -->
301 <target name="clean-list"
302 description="--> clean all projects">
303 <antcall target="build-list">
304 <param name="target" value="clean"/>
305 </antcall>
306 </target>
307
308 <!-- =================================
309 target: clean-all
310 ================================= -->
311 <target name="clean-all" depends="clean-list, clean"
312 description="--> clean repository, cache, and all projects">
313 <delete dir="${repository.dir}"/>
314 <delete dir="${cache.dir}"/>
315 <delete dir="${install.dir}"/>
316 <delete dir="${dist.dir}"/>
317 </target>
David Morgan Spenser Savagea4fbd5b2009-07-23 13:16:00 +0000318
David Morgan Spenser Savageeaad3e22009-09-15 08:11:02 +0000319 <property name="sigil.home" value="${cache.dir}/ant" />
David Morgan Spenser Savagea4fbd5b2009-07-23 13:16:00 +0000320 <property name="sigil.jar.dir" value="${sigil.home}/lib" />
321 <property name="ivy.jar.file" value="${sigil.jar.dir}/ivy.jar" />
322 <property name="sigil.jar.file" value="${sigil.jar.dir}/sigil-ivy-plugin.jar" />
323 <property name="bnd.jar.file" value="${sigil.jar.dir}/bndlib.jar" />
324 <property name="equinox.common.jar.file" value="${sigil.jar.dir}/equinox.common.jar" />
325
326
327 <target name="download-deps" unless="offline">
328 <property name="deps.loaded" value="true"/>
329 <mkdir dir="${sigil.jar.dir}"/>
330 <!-- ivy -->
331 <get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
332 dest="${ivy.jar.file}" usetimestamp="true" verbose="true"/>
333 <!-- sigil -->
334 <get src="http://people.apache.org/~dsavage/sigil/sigil-ivy-plugin.jar"
335 dest="${sigil.jar.file}" usetimestamp="true" verbose="true"/>
336 <!-- bnd -->
337 <get src="http://www.aQute.biz/repo/biz/aQute/bndlib/${bnd.install.version}/bndlib-${bnd.install.version}.jar"
338 dest="${bnd.jar.file}" usetimestamp="true" verbose="true"/>
339 <!-- equinox.common -->
340 <get src=" http://download.eclipse.org/releases/${equinox.release}/plugins/org.eclipse.equinox.common_${equinox.install.version}.jar"
341 dest="${equinox.common.jar.file}" usetimestamp="true" verbose="true"/>
342 </target>
343
344 <target name="check-sigil">
345 <condition property="sigil.loaded">
346 <typefound name="sigil.bundle" />
347 </condition>
348 </target>
349
350 <target name="init-sigil" depends="check-sigil" unless="sigil.loaded">
351 <antcall target="download-deps" />
352 <!-- try to load ivy here from ivy home, in case the user has not already dropped
353 it into ant's lib dir (note that the latter copy will always take precedence).
354 We will not fail as long as local lib dir exists (it may be empty) and
355 ivy is in at least one of ant's lib dir or the local lib dir. -->
356 <path id="sigil.lib.path">
357 <fileset dir="${sigil.jar.dir}" includes="*.jar"/>
358 </path>
359
David Morgan Spenser Savagea4fbd5b2009-07-23 13:16:00 +0000360 <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"/>
David Morgan Spenser Savage0f102f92009-09-18 15:45:19 +0000368
David Morgan Spenser Savagea4fbd5b2009-07-23 13:16:00 +0000369 </target>
Richard S. Hall6fe36b42009-07-13 13:25:46 +0000370
Richard S. Hall6fe36b42009-07-13 13:25:46 +0000371</project>