view jacoco-ant.xml @ 145:cea4e793a3f4

handle merge working directories (multiple parent branches)
author Dave Smith <smith@nwoca.org>
date Fri, 25 Oct 2013 21:29:39 +0100
parents 9dcb429eea14
children
line wrap: on
line source
<?xml version="1.0" encoding="UTF-8"?>
<project name="jacoco-project-tasks" default="" basedir="."
         xmlns:ivy="antlib:fr.jayasoft.ivy.ant"
         xmlns:ssdt="http://www.ssdt-ohio.org/ant/common"
         xmlns:jacoco="antlib:org.jacoco.ant">

    <description>jacoco Ant tasks</description>

    <property name="jacoco.report.dir" value="build/jacoco"/>
    <property name="jacoco.data.file" value="build/jacoco/jacoco.exec"/>

    <target name="-check.jacoco" depends="project.init,ivy-info">
        <property           name="jacoco.ant.jar.file"
                            value="${user.home.ant.lib}/jacoco-ant.jar"/>
        <property           name="jacoco.agent.jar.file"
                            value="${ssdt.devel.kit}/jacoco-agent.jar"/>
        <property           name="ssdt.jacoco.ant.jar.src"
                            value="http://ivy.ssdt.nwoca.org/repository/jacoco/jacocoant.jar"/>
        <property           name="ssdt.jacoco.agent.jar.src"
                            value="http://ivy.ssdt.nwoca.org/repository/jacoco/jacocoagent.jar"/>
        <ssdt:fetch         dest="${jacoco.ant.jar.file}"
                            src="${ssdt.jacoco.ant.jar.src}"/>
        <ssdt:fetch         dest="${jacoco.agent.jar.file}"
                            src="${ssdt.jacoco.agent.jar.src}"/>
        <property name="jacoco.installed" value="true"/>
        <property name="jacoco.dir" value="${build.dir}/jacoco"/>

    </target>

    <target name="with.coverage" depends="-check.jacoco" if="jacoco.installed" unless="jacoco.disabled">
        <property name="coverage.run.with.jacoco" value="true"/>
        <mkdir dir="${jacoco.dir}"/>
        <copy file="${jacoco.agent.jar.file}" tofile="${jacoco.dir}/jacocoagent.jar"/>
        <property name="_jacoco.agentFile" value="${jacoco.dir}/jacocoagent.jar"/>
        <taskdef  uri="antlib:org.jacoco.ant"
                  classpath="${jacoco.ant.jar.file}"
                  resource="org/jacoco/ant/antlib.xml"/>
        <jacoco:agent property="jacoco.coverage.agent"
                      destfile="${jacoco.data.file}"/>
        <if><isset property="runmain.jvmargs"/>
            <then>
                <var name="runmain.jvmargs.jacoco" value="${runmain.jvmargs}"/>
                <var name="runmain.jvmargs" value="${jacoco.coverage.agent} ${runmain.jvmargs.jacoco}"/>  
            </then>
        </if>
        <if><isset property="run.jvmargs"/>
            <then>
                <var name="run.jvmargs.jacoco" value="${run.jvmargs}"/>
                <var name="run.jvmargs" value="${jacoco.coverage.agent} ${run.jvmargs.jacoco}"/>  
            </then>
        </if>
    </target>

    <target name="coverage.xml"
            description="Generates an XML converage report."
            depends="-check.jacoco,project.init"
            if="jacoco.installed">
        <if><available file="${jacoco.data.file}"/>
            <then>
                <mkdir dir="${jacoco.report.dir}"/>
                <jacoco:report>
                    <executiondata>
                        <file file="${jacoco.data.file}"/>
                    </executiondata>
                    <structure name="${ivy.project.module}">
                        <classfiles>
                            <fileset dir="${build.classes.dir}"/>
                        </classfiles>
                        <sourcefiles encoding="UTF-8">
                            <fileset dir="${src.dir}"/>
                        </sourcefiles>
                    </structure>
                    <xml destfile="${jacoco.report.dir}/jacoco.xml"/>
                </jacoco:report>
            </then>
            <else>
                <echo message="Coverage data not available. coverage.xml skipped"/>
            </else>
        </if>

    </target>

    <target name="coverage.html"
            description="Generates an HTML converage report."
            depends="-check.jacoco"
            if="jacoco.installed">
        <mkdir dir="${jacoco.report.dir}"/>
        <jacoco:report>
            <executiondata>
                <file file="${jacoco.data.file}"/>
            </executiondata>
            <structure name="${ivy.project.module}">
                <classfiles>
                    <fileset dir="${build.classes.dir}"/>
                </classfiles>
                <sourcefiles encoding="UTF-8">
                    <fileset dir="${src.dir}"/>
                </sourcefiles>
            </structure>
            <html destdir="${jacoco.report.dir}"/>
        </jacoco:report>
    </target>

</project>