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