blob: 835e34d3a7c4c4dbf5e2e86669be15d5a543b33c [file] [log] [blame]
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project name="bldcommon"
xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:groovy="antlib:org.codehaus.groovy">
<dirname property="common.dir" file="${ant.file.bldcommon}"/>
<property file="${common.dir}/sigil-defaults.properties" prefix="default."/>
<property file="${common.dir}/build.properties"/>
<echo>${cache.dir}</echo>
<!-- =====================================================
stuff intended to be over-ridden is prefixed with my.
=====================================================-->
<fileset id="my.projects" dir="${basedir}">
<include name="**/${build_xml}"/>
</fileset>
<path id="my.classpath">
<fileset dir="${basedir}" includes="lib/*.jar"/>
</path>
<path id="javac.classpath">
<path refid="my.classpath"/>
<fileset dir="${deps.dir}" />
</path>
<path id="sigil.classpath">
<path refid="javac.classpath" />
<path location="${classes.dir}" />
</path>
<!-- =================================
target: load-ivy
================================= -->
<target name="load-ivy" depends="init-sigil">
<echo message="Loading Ivy ... ${common.dir}/ivysettings.xml"/>
<ivy:settings file="${common.dir}/ivysettings.xml" />
</target>
<target name="load-groovy">
<ivy:cachepath
organisation="org.codehaus.groovy"
module="groovy-all"
revision="1.6.4"
inline="true"
pathid="groovy.classpath"
transitive="false"
log="quiet"/>
<taskdef resource="org/codehaus/groovy/antlib.xml"
uri="antlib:org.codehaus.groovy" classpathref="groovy.classpath"/>
</target>
<!-- =================================
target: build (default target)
================================= -->
<target name="build" depends="publish-local" />
<target name="ident">
<echo message="${ant.project.name}"/>
</target>
<!-- =================================
target: resolve
================================= -->
<target name="resolve" depends="common-init"
description="--> resolve and retrieve dependencies with ivy">
<mkdir dir="${deps.dir}"/>
<ivy:resolve file="${ivy.file}" log="${resolve.log}"/>
<ivy:retrieve pattern="${deps.dir}/[artifact].[ext]"
symlink="true" sync="true"/>
<!-- sync=true removes empty deps dir, so re-create it -->
<mkdir dir="${deps.dir}"/>
</target>
<!-- =================================
target: publish-local
================================= -->
<target name="publish-check" unless="bundle.modified">
<ivy:info file="${ivy.file}"/>
<condition property="bundle.modified">
<not>
<available file="${repository.dir}/local/${ivy.module}" type="dir"/>
</not>
</condition>
</target>
<target name="publish-local" depends="bundle, publish-check" if="bundle.modified"
description="--> publish project in the local repository">
<tstamp>
<format property="now" pattern="yyyyMMddHHmmss"/>
</tstamp>
<property name="local-version" value="${now}"/>
<antcall target="clean-local"/>
<ivy:publish artifactspattern="${build.lib.dir}/[artifact].[ext]"
resolver="local"
pubrevision="${local-version}"
pubdate="${now}"
forcedeliver="true"
status="integration"/>
<echo message="project ${ant.project.name} published locally with version ${local-version}" />
</target>
<!-- =================================
target: report
================================= -->
<target name="report" depends="resolve"
description="--> generates a report of dependencies">
<ivy:report todir="${build.dir}"/>
</target>
<!-- =================================
target: compile
================================= -->
<target name="compile" depends="resolve"
description="--> compile the project">
<!-- uncomment the following to debug classpath -->
<!--pathconvert property="cp" refid="javac.classpath"/>
<echo>Classpath - ${cp}</echo-->
<mkdir dir="${classes.dir}" />
<javac srcdir="${src.dir}"
destdir="${classes.dir}"
classpathref="javac.classpath"
target="1.5"
debug="true" />
</target>
<!-- =================================
target: bundle
================================= -->
<target name="bundle" depends="compile"
description="--> build OSGi bundle(s) for this project">
<mkdir dir="${build.lib.dir}"/>
<sigil.bundle
classpathref="sigil.classpath"
destpattern="${build.lib.dir}/[name].[ext]"
force="${bundle.force}"
property="bundle.modified" />
</target>
<available file="bin" type="dir"
property="bin.dir.present"/>
<available file="etc" type="dir"
property="etc.dir.present"/>
<target name="install-bin" if="bin.dir.present">
<mkdir dir="${install.dir}/bin"/>
<copy todir="${install.dir}/bin">
<fileset dir="bin" />
</copy>
<chmod dir="${install.dir}/bin" perm="755" excludes="*.bat"/>
</target>
<target name="install-etc" if="etc.dir.present">
<mkdir dir="${install.dir}/etc"/>
<copy todir="${install.dir}/etc">
<fileset dir="etc" />
</copy>
</target>
<target name="libs-available">
<available file="${build.lib.dir}" type="dir"
property="build.lib.dir.present"/>
</target>
<target name="install-lib"
depends="publish-local, libs-available"
if="build.lib.dir.present">
<copy todir="${install.dir}/lib">
<fileset dir="${build.lib.dir}" />
<mapper type="glob" from="*.jar" to="*-${buildVersion}.jar"/>
</copy>
</target>
<!-- =================================
target: clean-local
================================= -->
<target name="clean-local" depends="boot"
description="--> cleans the local repository for the current module">
<ivy:info file="${ivy.file}"/>
<delete dir="${repository.dir}/local/${ivy.module}"/>
</target>
<!-- =================================
target: clean-deps
================================= -->
<target name="clean-deps"
description="--> clean the project dependencies directory">
<delete includeemptydirs="true" dir="${deps.dir}"/>
</target>
<!-- =================================
target: clean-build
================================= -->
<target name="clean-build"
description="--> clean the project built files">
<delete includeemptydirs="true" dir="${build.dir}"/>
</target>
<!-- =================================
target: clean
================================= -->
<target name="clean" depends="ident, clean-build, clean-deps"
description="--> clean the project" />
<!-- =================================
target: boot
================================= -->
<target name="boot" depends="load-ivy,load-groovy">
</target>
<!-- =================================
target: common-init
================================= -->
<target name="common-init" depends="ident,boot,init">
</target>
<!-- =================================
target: init
================================= -->
<target name="init">
</target>
<!-- =================================
target: buildlist
================================= -->
<target name="buildlist" depends="common-init">
<ivy:buildlist reference="ordered-list"
onMissingDescriptor="skip">
<fileset refid="my.projects"/>
</ivy:buildlist>
</target>
<!-- =================================
target: build-list
================================= -->
<target name="build-list" depends="buildlist"
description="--> build all projects in the right order">
<property name="target" value="build"/>
<subant target="${target}" buildpathref="ordered-list">
<propertyset>
<propertyref name="ivy.loaded" />
</propertyset>
</subant>
</target>
<!-- =================================
target: report-list
================================= -->
<target name="report-list"
description="--> report all projects">
<antcall target="build-list">
<param name="target" value="report"/>
</antcall>
</target>
<!-- =================================
target: install-list
================================= -->
<target name="install-list"
description="--> install all projects">
<antcall target="build-list">
<param name="target" value="install"/>
</antcall>
</target>
<!-- =================================
target: ident-list
================================= -->
<target name="ident-list"
description="--> identify projects">
<antcall target="build-list">
<param name="target" value="ident"/>
</antcall>
</target>
<!-- =================================
target: clean-list
================================= -->
<target name="clean-list"
description="--> clean all projects">
<antcall target="build-list">
<param name="target" value="clean"/>
</antcall>
</target>
<!-- =================================
target: clean-all
================================= -->
<target name="clean-all" depends="clean-list, clean"
description="--> clean repository, cache, and all projects">
<delete dir="${repository.dir}"/>
<delete dir="${cache.dir}"/>
<delete dir="${install.dir}"/>
<delete dir="${dist.dir}"/>
</target>
<property name="sigil.home" value="${cache.dir}/ant" />
<property name="sigil.jar.dir" value="${sigil.home}/lib" />
<property name="ivy.jar.file" value="${sigil.jar.dir}/ivy.jar" />
<property name="sigil.jar.file" value="${sigil.jar.dir}/sigil-ivy-plugin.jar" />
<property name="bnd.jar.file" value="${sigil.jar.dir}/bndlib.jar" />
<property name="equinox.common.jar.file" value="${sigil.jar.dir}/equinox.common.jar" />
<target name="download-deps" unless="offline">
<property name="deps.loaded" value="true"/>
<mkdir dir="${sigil.jar.dir}"/>
<!-- ivy -->
<get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
dest="${ivy.jar.file}" usetimestamp="true" verbose="true"/>
<!-- sigil -->
<get src="http://people.apache.org/~dsavage/sigil/sigil-ivy-plugin.jar"
dest="${sigil.jar.file}" usetimestamp="true" verbose="true"/>
<!-- bnd -->
<get src="http://www.aQute.biz/repo/biz/aQute/bndlib/${bnd.install.version}/bndlib-${bnd.install.version}.jar"
dest="${bnd.jar.file}" usetimestamp="true" verbose="true"/>
<!-- equinox.common -->
<get src=" http://download.eclipse.org/releases/${equinox.release}/plugins/org.eclipse.equinox.common_${equinox.install.version}.jar"
dest="${equinox.common.jar.file}" usetimestamp="true" verbose="true"/>
</target>
<target name="check-sigil">
<condition property="sigil.loaded">
<typefound name="sigil.bundle" />
</condition>
</target>
<target name="init-sigil" depends="check-sigil" unless="sigil.loaded">
<antcall target="download-deps" />
<!-- try to load ivy here from ivy home, in case the user has not already dropped
it into ant's lib dir (note that the latter copy will always take precedence).
We will not fail as long as local lib dir exists (it may be empty) and
ivy is in at least one of ant's lib dir or the local lib dir. -->
<path id="sigil.lib.path">
<fileset dir="${sigil.jar.dir}" includes="*.jar"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant" classpathref="sigil.lib.path"/>
<taskdef name="sigil.bundle"
classname="org.apache.felix.sigil.ant.BundleTask" classpathref="sigil.lib.path"/>
<taskdef name="sigil.bundle.info"
classname="org.apache.felix.sigil.ant.BundleInfoTask" classpathref="sigil.lib.path"/>
</target>
</project>