Richard S. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 1 | <?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 Savage | 3b1b8c8 | 2009-07-20 21:01:49 +0000 | [diff] [blame] | 20 | <project name="bldcommon" |
Richard S. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 21 | xmlns:ivy="antlib:org.apache.ivy.ant"> |
| 22 | |
David Morgan Spenser Savage | 3b1b8c8 | 2009-07-20 21:01:49 +0000 | [diff] [blame] | 23 | <dirname property="common.dir" file="${ant.file.bldcommon}"/> |
Richard S. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 24 | <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 Savage | a4fbd5b | 2009-07-23 13:16:00 +0000 | [diff] [blame] | 52 | <target name="load-ivy" depends="init-sigil"> |
| 53 | <echo message="Loading Ivy ... common.dir=${common.dir}"/> |
Richard S. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 54 | <ivy:settings file="${common.dir}/ivysettings.xml" /> |
| 55 | </target> |
| 56 | |
| 57 | <!-- ================================= |
Richard S. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 58 | target: build (default target) |
| 59 | ================================= --> |
| 60 | <target name="build" depends="publish-local, composites" /> |
| 61 | |
| 62 | <target name="ident"> |
| 63 | <echo message="${ant.project.name}"/> |
| 64 | </target> |
| 65 | |
| 66 | <!-- ================================= |
| 67 | target: resolve |
| 68 | ================================= --> |
David Morgan Spenser Savage | 7478b7b | 2009-07-22 19:15:19 +0000 | [diff] [blame] | 69 | <target name="resolve" depends="common-init" |
Richard S. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 70 | 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 Savage | 2c18241 | 2009-07-21 20:42:53 +0000 | [diff] [blame] | 124 | <!--pathconvert property="cp" refid="javac.classpath"/> |
| 125 | <echo>Classpath - ${cp}</echo--> |
Richard S. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 126 | <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 | <!-- ================================= |
| 148 | target: composites |
| 149 | ================================= --> |
| 150 | <available file="${composite.dir}" type="dir" |
| 151 | property="composite.dir.present"/> |
| 152 | |
| 153 | <target name="composites" if="composite.dir.present" |
| 154 | description="--> filter xml composites replacing ${VERSION} etc."> |
| 155 | <mkdir dir="${build.etc.dir}"/> |
| 156 | <copy todir="${build.etc.dir}"> |
| 157 | <fileset dir="${composite.dir}"> |
| 158 | <exclude name="*-template.composite"/> |
| 159 | <include name="*.composite"/> |
| 160 | <include name="*.system"/> |
| 161 | </fileset> |
| 162 | <filterset begintoken="@" endtoken="@"> |
| 163 | <filter token="VERSION" value="${bundle.version}"/> |
| 164 | <filter token="COMMUNITY_VERSION" value="${community.version}"/> |
| 165 | <filter token="JINI_VERSION" value="${jini.version}"/> |
| 166 | <filter token="PAREMUS_VERSION" value="${paremus.version}"/> |
| 167 | </filterset> |
| 168 | </copy> |
| 169 | </target> |
| 170 | |
| 171 | <!-- ================================= |
| 172 | target: install |
| 173 | install-bin, install-etc deprecated in favour of single |
| 174 | assemble/bin, assemble/etc dirs |
| 175 | ================================= --> |
| 176 | <target name="install" |
| 177 | depends="install-lib, install-composites"/> |
| 178 | |
| 179 | <available file="bin" type="dir" |
| 180 | property="bin.dir.present"/> |
| 181 | <available file="etc" type="dir" |
| 182 | property="etc.dir.present"/> |
| 183 | |
| 184 | <target name="install-bin" if="bin.dir.present"> |
| 185 | <mkdir dir="${install.dir}/bin"/> |
| 186 | <copy todir="${install.dir}/bin"> |
| 187 | <fileset dir="bin" /> |
| 188 | </copy> |
| 189 | <chmod dir="${install.dir}/bin" perm="755" excludes="*.bat"/> |
| 190 | </target> |
| 191 | |
| 192 | <target name="install-etc" if="etc.dir.present"> |
| 193 | <mkdir dir="${install.dir}/etc"/> |
| 194 | <copy todir="${install.dir}/etc"> |
| 195 | <fileset dir="etc" /> |
| 196 | </copy> |
| 197 | </target> |
| 198 | |
| 199 | <target name="composites-available"> |
| 200 | <available file="${build.etc.dir}" type="dir" |
| 201 | property="build.etc.dir.present"/> |
| 202 | </target> |
| 203 | |
| 204 | <target name="install-composites" |
| 205 | depends="composites, composites-available" |
| 206 | if="build.etc.dir.present"> |
| 207 | <copy todir="${install.dir}/etc"> |
| 208 | <fileset dir="${build.etc.dir}" /> |
| 209 | </copy> |
| 210 | </target> |
| 211 | |
| 212 | <target name="libs-available"> |
| 213 | <available file="${build.lib.dir}" type="dir" |
| 214 | property="build.lib.dir.present"/> |
| 215 | </target> |
| 216 | |
| 217 | <target name="install-lib" |
| 218 | depends="publish-local, libs-available" |
| 219 | if="build.lib.dir.present"> |
| 220 | <copy todir="${install.dir}/lib"> |
| 221 | <fileset dir="${build.lib.dir}" /> |
| 222 | <mapper type="glob" from="*.jar" to="*-${buildVersion}.jar"/> |
| 223 | </copy> |
| 224 | </target> |
| 225 | |
| 226 | <!-- ================================= |
| 227 | target: clean-local |
| 228 | ================================= --> |
David Morgan Spenser Savage | a4fbd5b | 2009-07-23 13:16:00 +0000 | [diff] [blame] | 229 | <target name="clean-local" depends="boot" |
Richard S. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 230 | description="--> cleans the local repository for the current module"> |
| 231 | <ivy:info file="${ivy.file}"/> |
| 232 | <delete dir="${repository.dir}/local/${ivy.module}"/> |
| 233 | </target> |
| 234 | |
| 235 | <!-- ================================= |
| 236 | target: clean-deps |
| 237 | ================================= --> |
| 238 | <target name="clean-deps" |
| 239 | description="--> clean the project dependencies directory"> |
| 240 | <delete includeemptydirs="true" dir="${deps.dir}"/> |
| 241 | </target> |
| 242 | |
| 243 | <!-- ================================= |
| 244 | target: clean-build |
| 245 | ================================= --> |
| 246 | <target name="clean-build" |
| 247 | description="--> clean the project built files"> |
| 248 | <delete includeemptydirs="true" dir="${build.dir}"/> |
| 249 | </target> |
| 250 | |
| 251 | <!-- ================================= |
| 252 | target: clean |
| 253 | ================================= --> |
| 254 | <target name="clean" depends="ident, clean-build, clean-deps" |
| 255 | description="--> clean the project" /> |
| 256 | |
| 257 | |
| 258 | <!-- ================================= |
David Morgan Spenser Savage | a4fbd5b | 2009-07-23 13:16:00 +0000 | [diff] [blame] | 259 | target: boot |
| 260 | ================================= --> |
| 261 | <target name="boot" depends="load-ivy"> |
| 262 | </target> |
| 263 | |
| 264 | <!-- ================================= |
David Morgan Spenser Savage | 7478b7b | 2009-07-22 19:15:19 +0000 | [diff] [blame] | 265 | target: common-init |
| 266 | ================================= --> |
David Morgan Spenser Savage | a4fbd5b | 2009-07-23 13:16:00 +0000 | [diff] [blame] | 267 | <target name="common-init" depends="ident,boot,init"> |
David Morgan Spenser Savage | 7478b7b | 2009-07-22 19:15:19 +0000 | [diff] [blame] | 268 | </target> |
| 269 | |
| 270 | <!-- ================================= |
| 271 | target: init |
| 272 | ================================= --> |
| 273 | <target name="init"> |
| 274 | </target> |
| 275 | |
| 276 | <!-- ================================= |
Richard S. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 277 | target: buildlist |
| 278 | ================================= --> |
David Morgan Spenser Savage | 7478b7b | 2009-07-22 19:15:19 +0000 | [diff] [blame] | 279 | <target name="buildlist" depends="common-init"> |
Richard S. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 280 | <ivy:buildlist reference="ordered-list" |
| 281 | onMissingDescriptor="skip"> |
| 282 | <fileset refid="my.projects"/> |
| 283 | </ivy:buildlist> |
| 284 | </target> |
| 285 | |
| 286 | <!-- ================================= |
| 287 | target: build-list |
| 288 | ================================= --> |
| 289 | <target name="build-list" depends="buildlist" |
| 290 | description="--> build all projects in the right order"> |
| 291 | <property name="target" value="build"/> |
| 292 | <subant target="${target}" buildpathref="ordered-list"> |
| 293 | <propertyset> |
| 294 | <propertyref name="ivy.loaded" /> |
| 295 | </propertyset> |
| 296 | </subant> |
| 297 | </target> |
| 298 | |
| 299 | <!-- ================================= |
| 300 | target: install-list |
| 301 | ================================= --> |
| 302 | <target name="install-list" |
| 303 | description="--> install all projects"> |
| 304 | <antcall target="build-list"> |
| 305 | <param name="target" value="install"/> |
| 306 | </antcall> |
| 307 | </target> |
| 308 | |
| 309 | <!-- ================================= |
| 310 | target: ident-list |
| 311 | ================================= --> |
| 312 | <target name="ident-list" |
| 313 | description="--> identify projects"> |
| 314 | <antcall target="build-list"> |
| 315 | <param name="target" value="ident"/> |
| 316 | </antcall> |
| 317 | </target> |
| 318 | |
| 319 | <!-- ================================= |
| 320 | target: clean-list |
| 321 | ================================= --> |
| 322 | <target name="clean-list" |
| 323 | description="--> clean all projects"> |
| 324 | <antcall target="build-list"> |
| 325 | <param name="target" value="clean"/> |
| 326 | </antcall> |
| 327 | </target> |
| 328 | |
| 329 | <!-- ================================= |
| 330 | target: clean-all |
| 331 | ================================= --> |
| 332 | <target name="clean-all" depends="clean-list, clean" |
| 333 | description="--> clean repository, cache, and all projects"> |
| 334 | <delete dir="${repository.dir}"/> |
| 335 | <delete dir="${cache.dir}"/> |
| 336 | <delete dir="${install.dir}"/> |
| 337 | <delete dir="${dist.dir}"/> |
| 338 | </target> |
David Morgan Spenser Savage | a4fbd5b | 2009-07-23 13:16:00 +0000 | [diff] [blame] | 339 | |
| 340 | <condition property="ivy.home" value="${env.SIGIL_HOME}"> |
| 341 | <isset property="env.SIGIL_HOME" /> |
| 342 | </condition> |
| 343 | |
David Morgan Spenser Savage | f3f70c2 | 2009-07-23 15:23:30 +0000 | [diff] [blame] | 344 | <property name="sigil.home" value="${common.dir}/../cache/ant" /> |
David Morgan Spenser Savage | a4fbd5b | 2009-07-23 13:16:00 +0000 | [diff] [blame] | 345 | <property name="sigil.jar.dir" value="${sigil.home}/lib" /> |
| 346 | <property name="ivy.jar.file" value="${sigil.jar.dir}/ivy.jar" /> |
| 347 | <property name="sigil.jar.file" value="${sigil.jar.dir}/sigil-ivy-plugin.jar" /> |
| 348 | <property name="bnd.jar.file" value="${sigil.jar.dir}/bndlib.jar" /> |
| 349 | <property name="equinox.common.jar.file" value="${sigil.jar.dir}/equinox.common.jar" /> |
| 350 | |
| 351 | |
| 352 | <target name="download-deps" unless="offline"> |
| 353 | <property name="deps.loaded" value="true"/> |
| 354 | <mkdir dir="${sigil.jar.dir}"/> |
| 355 | <!-- ivy --> |
| 356 | <get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar" |
| 357 | dest="${ivy.jar.file}" usetimestamp="true" verbose="true"/> |
| 358 | <!-- sigil --> |
| 359 | <get src="http://people.apache.org/~dsavage/sigil/sigil-ivy-plugin.jar" |
| 360 | dest="${sigil.jar.file}" usetimestamp="true" verbose="true"/> |
| 361 | <!-- bnd --> |
| 362 | <get src="http://www.aQute.biz/repo/biz/aQute/bndlib/${bnd.install.version}/bndlib-${bnd.install.version}.jar" |
| 363 | dest="${bnd.jar.file}" usetimestamp="true" verbose="true"/> |
| 364 | <!-- equinox.common --> |
| 365 | <get src=" http://download.eclipse.org/releases/${equinox.release}/plugins/org.eclipse.equinox.common_${equinox.install.version}.jar" |
| 366 | dest="${equinox.common.jar.file}" usetimestamp="true" verbose="true"/> |
| 367 | </target> |
| 368 | |
| 369 | <target name="check-sigil"> |
| 370 | <condition property="sigil.loaded"> |
| 371 | <typefound name="sigil.bundle" /> |
| 372 | </condition> |
| 373 | </target> |
| 374 | |
| 375 | <target name="init-sigil" depends="check-sigil" unless="sigil.loaded"> |
| 376 | <antcall target="download-deps" /> |
| 377 | <!-- try to load ivy here from ivy home, in case the user has not already dropped |
| 378 | it into ant's lib dir (note that the latter copy will always take precedence). |
| 379 | We will not fail as long as local lib dir exists (it may be empty) and |
| 380 | ivy is in at least one of ant's lib dir or the local lib dir. --> |
| 381 | <path id="sigil.lib.path"> |
| 382 | <fileset dir="${sigil.jar.dir}" includes="*.jar"/> |
| 383 | </path> |
| 384 | |
| 385 | <echo>Initialising sigil with ${sigil.jar.dir}</echo> |
| 386 | |
| 387 | <taskdef resource="org/apache/ivy/ant/antlib.xml" |
| 388 | uri="antlib:org.apache.ivy.ant" classpathref="sigil.lib.path"/> |
| 389 | |
| 390 | <taskdef name="sigil.bundle" |
| 391 | classname="org.apache.felix.sigil.ant.BundleTask" classpathref="sigil.lib.path"/> |
| 392 | |
| 393 | <taskdef name="sigil.bundle.info" |
| 394 | classname="org.apache.felix.sigil.ant.BundleInfoTask" classpathref="sigil.lib.path"/> |
| 395 | </target> |
Richard S. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 396 | |
Richard S. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 397 | </project> |