blob: 514f231832af0d21f49759b22884a91e4fb665c0 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<project name="org.jacoco.build.bundle" default="package" xmlns:jacoco="antlib:org.jacoco.ant">
<description>
This build file is executed for every JaCoCo bundle. Every bundle must
contain a buildhook.xml file that gets imported into this build file and
customizes the specific build actions for the bundle.
</description>
<property name="source.bundle.dir" location="${basedir}"/>
<property name="source.bundle.java.dir" location="${source.bundle.dir}/src"/>
<!-- Additional resources to include with the compiled classes. By default
none, can be overwritten by the build hook. -->
<fileset dir="${source.bundle.java.dir}" excludes="**/*" id="classpathresources"/>
<import file="${source.bundle.dir}/buildhook.xml"/>
<!-- ===================================================================
COMPILE
=================================================================== -->
<target name="compile" if="do.compile">
<property name="result.tmp.bundle.classes.dir" location="${result.tmp.bundle.dir}/classes"/>
<mkdir dir="${result.tmp.bundle.classes.dir}"/>
<javac srcdir="${source.bundle.java.dir}" destdir="${result.tmp.bundle.classes.dir}"
debug="true" source="1.5" target="1.5">
<classpath refid="dependencies"/>
</javac>
<copy todir="${result.tmp.bundle.classes.dir}">
<fileset refid="classpathresources"/>
</copy>
</target>
<!-- ===================================================================
PACKAGE
=================================================================== -->
<target name="manifest">
<property name="source.bundle.manifest.file" location="${source.bundle.dir}/META-INF/MANIFEST.MF"/>
<property name="result.temp.bundle.manifest.file" location="${result.tmp.bundle.dir}/MANIFEST.MF"/>
<copy file="${source.bundle.manifest.file}" tofile="${result.temp.bundle.manifest.file}"/>
<replace file="${result.temp.bundle.manifest.file}" token="qualifier" value="${build.qualifier}"/>
<property prefix="manifest" file="${result.temp.bundle.manifest.file}"/>
<property name="qualified.bundle.version" value="${manifest.Bundle-Version}"/>
</target>
<target name="runcustompackage" if="do.custompackage" depends="manifest">
<antcall target="custompackage" inheritall="true" inheritrefs="true"/>
</target>
<target name="package" if="do.package" depends="compile,runcustompackage,manifest">
<property name="result.dist.bundle.jar.file" location="${result.dist.lib.dir}/${manifest.Bundle-SymbolicName}_${qualified.bundle.version}.jar"/>
<mkdir dir="${result.dist.lib.dir}"/>
<jar destfile="${result.dist.bundle.jar.file}" manifest="${result.temp.bundle.manifest.file}" level="9">
<fileset dir="${result.tmp.bundle.classes.dir}"/>
<fileset file="${source.bundle.dir}/about.html"/>
</jar>
</target>
<!-- ===================================================================
VERIFY
=================================================================== -->
<target name="runcustomverify" if="do.customverify">
<antcall target="customverify" inheritall="true" inheritrefs="true"/>
</target>
<target name="verify" if="do.verify" depends="package,runcustomverify">
<!-- of course we meassure code coverage for JaCoCo tests -->
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath>
<file file="${result.dist.lib.dir}/jacocoant.jar"/>
</classpath>
</taskdef>
<property name="result.tmp.bundle.test.dir" location="${result.tmp.bundle.dir}/test"/>
<mkdir dir="${result.tmp.bundle.test.dir}"/>
<jacoco:coverage
merge="true"
file="${result.tmp.coverage.file}"
exclClassLoader="sun.reflect.DelegatingClassLoader|org.jacoco.core.test.TargetLoader">
<junit haltonfailure="true" fork="true" forkmode="once">
<batchtest todir="${result.tmp.bundle.test.dir}" >
<fileset dir="${result.tmp.bundle.classes.dir}">
<include name="**/*Test.class"/>
</fileset>
</batchtest>
<classpath>
<pathelement location="${result.tmp.bundle.classes.dir}"/>
<path refid="dependencies"/>
</classpath>
<formatter type="xml"/>
</junit>
</jacoco:coverage>
</target>
<!-- ===================================================================
DOC
=================================================================== -->
<target name="doc" if="do.customdoc" depends="manifest">
<antcall target="customdoc" inheritall="true" inheritrefs="true"/>
</target>
<!-- ===================================================================
ALL
=================================================================== -->
<target name="all" depends="compile,package,verify,doc"/>
</project>