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