blob: 68f1ecbcbefd0f5f86fbcacdb91206b07de49de9 [file] [log] [blame]
<!--
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="ivy" default="coverage-report" xmlns:ivy="antlib:fr.jayasoft.ivy.ant">
<property environment="env"/>
<property file="version.properties"/>
<property file="build.properties"/>
<!-- =================================================================
IVY AUTO INSTALL
Ivy eats its own dog food, and thus require Ivy jar to
be built. This section will download Ivy from
internet and use it for ivy tasks of this build.
================================================================= -->
<property name="final.name" value="ivy.jar" />
<property name="final.core.name" value="ivy-core.jar" />
<target name="init-ivy-user-home" unless="ivy.use.local.home">
<condition property="ivy.home" value="${env.IVY_HOME}">
<isset property="env.IVY_HOME" />
</condition>
<property name="ivy.home" value="${user.home}/.ivy" />
</target>
<target name="init-ivy-local-home" if="ivy.use.local.home">
<property name="ivy.home" value="${basedir}/.ivy" />
</target>
<target name="init-ivy-jar">
<property name="ivy.jar.dir" value="${ivy.home}/jars" />
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />
</target>
<target name="init-ivy-home" depends="init-ivy-user-home, init-ivy-local-home, init-ivy-jar" />
<target name="download-ivy" depends="init-ivy-home" unless="offline">
<mkdir dir="${ivy.jar.dir}"/>
<!-- download Ivy from web site so that it can be used even without any special installation -->
<!-- use a non standard location during migration to apache -->
<get src="http://people.apache.org/~antoine/ivy/ivy-${ivy.install.version}.jar"
dest="${ivy.jar.file}" usetimestamp="true"/>
</target>
<target name="check-ivy-available" depends="init-ivy-home">
<path id="ivy.lib.path">
<fileset dir="${ivy.jar.dir}" includes="*.jar"/>
</path>
<available property="ivy.available" resource="fr/jayasoft/ivy/ant/antlib.xml"
classpathref="ivy.lib.path" />
</target>
<target name="init-ivy" depends="download-ivy,check-ivy-available" if="ivy.available">
<!-- try to load ivy here from local ivy dir, 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. -->
<taskdef resource="fr/jayasoft/ivy/ant/antlib.xml"
uri="antlib:fr.jayasoft.ivy.ant" classpathref="ivy.lib.path"/>
<ivy:configure file="${basedir}/ivysettings.xml" /> <!-- not necessary with Ivy 2.0+ -->
</target>
<target name="install" depends="jar" description="build Ivy and install it in Ivy home for consecutive builds">
<copy file="${artifacts.build.dir}/${final.name}" tofile="${ivy.jar.file}"/>
</target>
<!-- =================================================================
PREPARATION, CLEANING AND FLAGS TASKS
================================================================= -->
<target name="init">
<path id="build.classpath">
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
</path>
<path id="run.classpath">
<path refid="build.classpath"/>
<pathelement location="${classes.build.dir}"/>
</path>
<path id="test.classpath">
<path refid="run.classpath"/>
<pathelement path="${test.build.dir}"/>
</path>
</target>
<target name="prepare" depends="init">
<mkdir dir="${classes.build.dir}"/>
<mkdir dir="${test.build.dir}"/>
<mkdir dir="${artifacts.build.dir}"/>
<mkdir dir="${test.report.dir}"/>
</target>
<target name="clean">
<delete dir="${classes.build.dir}"/>
<delete dir="${test.build.dir}"/>
<delete dir="${artifacts.build.dir}"/>
<delete dir="${test.report.dir}"/>
<delete dir="${javadoc.build.dir}"/>
<delete dir="${doc.build.dir}"/>
<delete dir="${build.dir}"/>
</target>
<target name="clean-lib">
<delete dir="${lib.dir}"/>
</target>
<target name="clean-ivy-cache" depends="init-ivy-home">
<delete dir="${ivy.home}/cache"/>
</target>
<target name="clean-ivy-home" depends="init-ivy-home">
<delete dir="${ivy.home}"/>
</target>
<target name="clean-examples" description="clean all examples">
<subant target="clean" failonerror="false">
<!-- use current ivy jar dir for nested calls, to avoid downloading ivy several times -->
<property name="ivy.jar.dir" value="${ivy.jar.dir}"/>
<fileset dir="src/example" includes="**/build.xml"/>
</subant>
</target>
<target name="clean-all" depends="clean, clean-lib, clean-examples"/>
<target name="noresolve" description="use to skip dependency resolution">
<property name="no.resolve" value="true"/>
</target>
<target name="notest" description="use to skip tests">
<property name="skip.test" value="true"/>
</target>
<target name="nojavadoc" description="use to skip javadoc">
<property name="skip.javadoc" value="true"/>
</target>
<target name="localivy" description="use a local ivy home">
<property name="ivy.use.local.home" value="true"/>
</target>
<target name="offline" depends="noresolve" description="use to indicate no internet connection is available">
<property name="offline" value="true" />
</target>
<target name="default-version">
<tstamp>
<format property="pubdate" pattern="yyyyMMddHHmmss"/>
</tstamp>
<property name="version.prefix" value="${target.ivy.version}-local-"/>
<property name="build.version" value="${version.prefix}${pubdate}"/>
<property name="bundle.version" value="${target.ivy.bundle.version}"/>
</target>
<!-- =================================================================
DEPENDENCY MNGT, COMPILATION AND JAR
================================================================= -->
<target name="resolve" depends="init-ivy, prepare" unless="no.resolve" if="ivy.available">
<ivy:retrieve conf="default,test" />
</target>
<target name="build" depends="resolve">
<javac srcdir="${src.dir}"
destdir="${classes.build.dir}"
classpathref="build.classpath"
source="${ivy.minimum.javaversion}"
target="${ivy.minimum.javaversion}"
debug="${debug.mode}"
includeantruntime="no"/>
</target>
<target name="jar" depends="build, default-version">
<!-- copy resources -->
<copy todir="${classes.build.dir}">
<fileset dir="${src.dir}">
<exclude name="**/*.java"/>
</fileset>
</copy>
<!-- copy antlib for backward compatibility with fr.jayasoft.ivy package -->
<copy file="${src.dir}/org/apache/ivy/ant/antlib.xml"
todir="${classes.build.dir}/fr/jayasoft/ivy/ant"/>
<!-- copy settings files for backward compatibility with ivyconf naming -->
<copy file="${classes.build.dir}/org/apache/ivy/core/settings/ivysettings-local.xml"
tofile="${classes.build.dir}/org/apache/ivy/core/settings/ivyconf-local.xml" />
<copy file="${classes.build.dir}/org/apache/ivy/core/settings/ivysettings-default-chain.xml"
tofile="${classes.build.dir}/org/apache/ivy/core/settings/ivyconf-default-chain.xml" />
<copy file="${classes.build.dir}/org/apache/ivy/core/settings/ivysettings-main-chain.xml"
tofile="${classes.build.dir}/org/apache/ivy/core/settings/ivyconf-main-chain.xml" />
<copy file="${classes.build.dir}/org/apache/ivy/core/settings/ivysettings-public.xml"
tofile="${classes.build.dir}/org/apache/ivy/core/settings/ivyconf-public.xml" />
<copy file="${classes.build.dir}/org/apache/ivy/core/settings/ivysettings-shared.xml"
tofile="${classes.build.dir}/org/apache/ivy/core/settings/ivyconf-shared.xml" />
<copy file="${classes.build.dir}/org/apache/ivy/core/settings/ivysettings.xml"
tofile="${classes.build.dir}/org/apache/ivy/core/settings/ivyconf.xml" />
<!-- identify compiled ivy version -->
<echo message="version=${build.version}${line.separator}" file="${classes.build.dir}/module.properties" append="true"/>
<echo message="date=${pubdate}${line.separator}" file="${classes.build.dir}/module.properties" append="true"/>
<!-- package the two ivy jars -->
<jar destfile="${artifacts.build.dir}/${final.name}"
basedir="${classes.build.dir}"
manifest="${basedir}/MANIFEST.MF">
<metainf dir="${basedir}" includes="LICENSE,DISCLAIMER,NOTICE" />
<manifest>
<attribute name="Build-Version" value="${build.version}"/>
<attribute name="Bundle-Version" value="${bundle.version}"/>
<section name="org/apache/ivy">
<attribute name="Extension-name" value="org.apache.ivy" />
<attribute name="Specification-Title" value="Apache Ivy" />
<attribute name="Specification-Version" value="${build.version}" />
<attribute name="Specification-Vendor" value="Apache Software Foundation" />
<attribute name="Implementation-Title" value="org.apache.tools.ant" />
<attribute name="Implementation-Version" value="${build.version}" />
<attribute name="Implementation-Vendor" value="Apache Software Foundation" />
</section>
</manifest>
</jar>
<jar destfile="${artifacts.build.dir}/${final.core.name}"
basedir="${classes.build.dir}"
excludes="org/apache/ivy/ant/*">
<metainf dir="${basedir}" includes="LICENSE,DISCLAIMER,NOTICE" />
<manifest>
<attribute name="Build-Version" value="${build.version}"/>
</manifest>
</jar>
<!-- clean generated module properties file -->
<delete file="${classes.build.dir}/module.properties"/>
</target>
<!-- =================================================================
PUBLISH LOCAL
================================================================= -->
<target name="publish-local" depends="jar" description="--> publishes Ivy to Ivy local repository">
<ivy:publish resolver="local" pubrevision="${build.version}"
artifactsPattern="${artifacts.build.dir}/[artifact].[ext]"
forcedeliver="true"/>
</target>
<!-- =================================================================
TESTS
================================================================= -->
<target name="build-custom-resolver-jar" depends="jar">
<mkdir dir="${build.dir}/custom-classpath" />
<javac srcdir="${basedir}/test/custom-classpath"
destdir="${build.dir}/custom-classpath"
classpathref="run.classpath"
source="${ivy.minimum.javaversion}"
target="${ivy.minimum.javaversion}"
debug="${debug.mode}"
includeantruntime="no"/>
<jar destfile="${test.dir}/org/apache/ivy/core/settings/custom-resolver.jar"
basedir="${build.dir}/custom-classpath"/>
</target>
<target name="init-tests-offline" if="offline">
<fileset id="test.fileset" dir="${test.dir}">
<include name="**/${test.class.pattern}.java"/>
<exclude name="**/Abstract*Test.java"/>
<contains text="junit"/>
<not><contains text="remote.test"/></not>
</fileset>
</target>
<target name="init-tests-online" unless="offline">
<fileset id="test.fileset" dir="${test.dir}">
<include name="**/${test.class.pattern}.java"/>
<exclude name="**/Abstract*Test.java"/>
<contains text="junit"/>
</fileset>
</target>
<target name="init-tests" depends="init-tests-offline, init-tests-online" />
<target name="emma" depends="jar" unless="skip.test" if="ivy.available">
<ivy:cachepath organisation="emma" module="emma" revision="2.0.5312"
inline="true" conf="ant" pathid="emma.classpath"/>
<taskdef resource="emma_ant.properties" classpathref="emma.classpath" />
<property name="emma.enabled" value="true" />
<property name="coverage.dir" value="${build.dir}/coverage" />
<mkdir dir="${coverage.dir}" />
<emma enabled="${emma.enabled}" >
<instr instrpath="${classes.build.dir}"
mode="overwrite"
metadatafile="${coverage.dir}/metadata.emma"
/>
</emma>
<delete file="${coverage.dir}/coverage.emma" />
<!-- add emma path to test path, because emma jars need to be available when running
instrumented classes -->
<ivy:addpath topath="test.classpath">
<path refid="emma.classpath"/>
</ivy:addpath>
</target>
<target name="build-test" depends="jar">
<javac srcdir="${test.dir}"
destdir="${test.build.dir}"
classpathref="run.classpath"
source="${ivy.minimum.javaversion}"
target="${ivy.minimum.javaversion}"
debug="${debug.mode}"
includeantruntime="no"/>
<copy todir="${test.build.dir}">
<fileset dir="${test.dir}">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="test-internal" depends="build-test, init-tests" unless="skip.test">
<mkdir dir="${test.xml.dir}" />
<junit
haltonfailure="off"
haltonerror="off"
errorproperty="test.failed"
failureproperty="test.failed"
showoutput="no"
printsummary="yes"
fork="true">
<classpath>
<path refid="test.classpath"/>
</classpath>
<jvmarg value="-Demma.coverage.out.file=${coverage.dir}/coverage.emma" />
<jvmarg value="-Demma.coverage.out.merge=true" />
<formatter type="xml"/>
<batchtest todir="${test.xml.dir}">
<fileset refid="test.fileset" />
</batchtest>
</junit>
</target>
<target name="test" depends="test-internal">
<fail if="test.failed"
message="At least one test has failed. See logs for details"/>
</target>
<!-- =================================================================
REPORTS AND DOCUMENTATION
================================================================= -->
<target name="test-report" depends="test-internal" unless="skip.test">
<junitreport todir="${test.xml.dir}">
<fileset dir="${test.xml.dir}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${test.report.dir}" />
</junitreport>
<fail if="test.failed"
message="At least one test has failed. See logs or report"/>
</target>
<target name="coverage-report" depends="emma, test-report" unless="skip.test"
description="run tests with instrumentation and generate coverage report">
<mkdir dir="${coverage.report.dir}" />
<emma>
<report sourcepath="${src.dir}" >
<fileset dir="${coverage.dir}" >
<include name="*.emma" />
</fileset>
<txt outfile="${coverage.report.dir}/coverage.txt" />
<html outfile="${coverage.report.dir}/coverage.html" />
</report>
</emma>
</target>
<target name="javadoc" unless="skip.javadoc">
<javadoc destdir="${javadoc.build.dir}">
<fileset dir="${src.dir}" includes="**/*.java,**/package.html"/>
</javadoc>
</target>
</project>