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}/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"> |
David Morgan Spenser Savage | 0f102f9 | 2009-09-18 15:45:19 +0000 | [diff] [blame] | 53 | <echo message="Loading Ivy ... ${common.dir}/ivysettings.xml"/> |
Richard S. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 54 | <ivy:settings file="${common.dir}/ivysettings.xml" /> |
| 55 | </target> |
| 56 | |
David Morgan Spenser Savage | 0f102f9 | 2009-09-18 15:45:19 +0000 | [diff] [blame] | 57 | <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. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 71 | <!-- ================================= |
Richard S. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 72 | target: build (default target) |
| 73 | ================================= --> |
David Morgan Spenser Savage | ef091e2 | 2009-09-11 20:50:48 +0000 | [diff] [blame] | 74 | <target name="build" depends="publish-local" /> |
Richard S. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 75 | |
| 76 | <target name="ident"> |
| 77 | <echo message="${ant.project.name}"/> |
| 78 | </target> |
| 79 | |
| 80 | <!-- ================================= |
| 81 | target: resolve |
| 82 | ================================= --> |
David Morgan Spenser Savage | 7478b7b | 2009-07-22 19:15:19 +0000 | [diff] [blame] | 83 | <target name="resolve" depends="common-init" |
Richard S. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 84 | 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 Savage | 2c18241 | 2009-07-21 20:42:53 +0000 | [diff] [blame] | 138 | <!--pathconvert property="cp" refid="javac.classpath"/> |
| 139 | <echo>Classpath - ${cp}</echo--> |
Richard S. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 140 | <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. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 161 | <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. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 181 | <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 Savage | a4fbd5b | 2009-07-23 13:16:00 +0000 | [diff] [blame] | 198 | <target name="clean-local" depends="boot" |
Richard S. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 199 | 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 Savage | a4fbd5b | 2009-07-23 13:16:00 +0000 | [diff] [blame] | 228 | target: boot |
| 229 | ================================= --> |
David Morgan Spenser Savage | 0f102f9 | 2009-09-18 15:45:19 +0000 | [diff] [blame] | 230 | <target name="boot" depends="load-ivy,load-groovy"> |
David Morgan Spenser Savage | a4fbd5b | 2009-07-23 13:16:00 +0000 | [diff] [blame] | 231 | </target> |
| 232 | |
| 233 | <!-- ================================= |
David Morgan Spenser Savage | 7478b7b | 2009-07-22 19:15:19 +0000 | [diff] [blame] | 234 | target: common-init |
| 235 | ================================= --> |
David Morgan Spenser Savage | a4fbd5b | 2009-07-23 13:16:00 +0000 | [diff] [blame] | 236 | <target name="common-init" depends="ident,boot,init"> |
David Morgan Spenser Savage | 7478b7b | 2009-07-22 19:15:19 +0000 | [diff] [blame] | 237 | </target> |
| 238 | |
| 239 | <!-- ================================= |
| 240 | target: init |
| 241 | ================================= --> |
| 242 | <target name="init"> |
| 243 | </target> |
| 244 | |
| 245 | <!-- ================================= |
Richard S. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 246 | target: buildlist |
| 247 | ================================= --> |
David Morgan Spenser Savage | 7478b7b | 2009-07-22 19:15:19 +0000 | [diff] [blame] | 248 | <target name="buildlist" depends="common-init"> |
Richard S. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 249 | <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 Savage | ef091e2 | 2009-09-11 20:50:48 +0000 | [diff] [blame] | 269 | 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. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 279 | 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 Savage | a4fbd5b | 2009-07-23 13:16:00 +0000 | [diff] [blame] | 318 | |
David Morgan Spenser Savage | eaad3e2 | 2009-09-15 08:11:02 +0000 | [diff] [blame] | 319 | <property name="sigil.home" value="${cache.dir}/ant" /> |
David Morgan Spenser Savage | a4fbd5b | 2009-07-23 13:16:00 +0000 | [diff] [blame] | 320 | <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" /> |
David Morgan Spenser Savage | a4fbd5b | 2009-07-23 13:16:00 +0000 | [diff] [blame] | 323 | |
| 324 | |
| 325 | <target name="download-deps" unless="offline"> |
| 326 | <property name="deps.loaded" value="true"/> |
| 327 | <mkdir dir="${sigil.jar.dir}"/> |
| 328 | <!-- ivy --> |
| 329 | <get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar" |
| 330 | dest="${ivy.jar.file}" usetimestamp="true" verbose="true"/> |
| 331 | <!-- sigil --> |
| 332 | <get src="http://people.apache.org/~dsavage/sigil/sigil-ivy-plugin.jar" |
| 333 | dest="${sigil.jar.file}" usetimestamp="true" verbose="true"/> |
David Morgan Spenser Savage | a4fbd5b | 2009-07-23 13:16:00 +0000 | [diff] [blame] | 334 | </target> |
| 335 | |
| 336 | <target name="check-sigil"> |
| 337 | <condition property="sigil.loaded"> |
| 338 | <typefound name="sigil.bundle" /> |
| 339 | </condition> |
| 340 | </target> |
| 341 | |
| 342 | <target name="init-sigil" depends="check-sigil" unless="sigil.loaded"> |
| 343 | <antcall target="download-deps" /> |
| 344 | <!-- try to load ivy here from ivy home, in case the user has not already dropped |
| 345 | it into ant's lib dir (note that the latter copy will always take precedence). |
| 346 | We will not fail as long as local lib dir exists (it may be empty) and |
| 347 | ivy is in at least one of ant's lib dir or the local lib dir. --> |
| 348 | <path id="sigil.lib.path"> |
| 349 | <fileset dir="${sigil.jar.dir}" includes="*.jar"/> |
| 350 | </path> |
| 351 | |
David Morgan Spenser Savage | a4fbd5b | 2009-07-23 13:16:00 +0000 | [diff] [blame] | 352 | <taskdef resource="org/apache/ivy/ant/antlib.xml" |
| 353 | uri="antlib:org.apache.ivy.ant" classpathref="sigil.lib.path"/> |
| 354 | |
| 355 | <taskdef name="sigil.bundle" |
| 356 | classname="org.apache.felix.sigil.ant.BundleTask" classpathref="sigil.lib.path"/> |
| 357 | |
| 358 | <taskdef name="sigil.bundle.info" |
| 359 | 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] | 360 | |
David Morgan Spenser Savage | a4fbd5b | 2009-07-23 13:16:00 +0000 | [diff] [blame] | 361 | </target> |
Richard S. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 362 | |
Richard S. Hall | 6fe36b4 | 2009-07-13 13:25:46 +0000 | [diff] [blame] | 363 | </project> |