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