maven-plugins/clover/plugin.jelly
evenisse 9a278f5c42 Update to ASL v.2
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@114791 13f79535-47bb-0310-9956-ffa450edef68
2004-03-04 18:05:31 +00:00

256 lines
9.0 KiB
XML

<?xml version="1.0"?>
<!--
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed 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
xmlns:j="jelly:core"
xmlns:ant="jelly:ant"
xmlns:maven="jelly:maven"
xmlns:java="java"
xmlns:test="test"
xmlns:doc="doc"
xmlns:u="jelly:util">
<java:dependency-handle/>
<j:set var="javaPlugin" value="${pom.getPluginContext('maven-java-plugin')}"/>
<test:dependency-handle/>
<j:set var="testPlugin" value="${pom.getPluginContext('maven-test-plugin')}"/>
<ant:path id="clover.classpath">
<j:choose>
<j:when test="${context.getVariable('maven.clover.jar') != null}">
<ant:pathelement path="${maven.clover.jar}"/>
</j:when>
<j:otherwise>
<ant:pathelement path="${plugin.getDependencyPath('clover')}"/>
</j:otherwise>
</j:choose>
</ant:path>
<goal name="maven-clover-plugin:register">
<j:if test="${sourcesPresent == 'true'}">
<doc:registerReport
name="Clover"
pluginName="maven-clover-plugin"
link="clover/index"
description="Clover test coverage report."/>
</j:if>
</goal>
<goal name="maven-clover-plugin:deregister">
<j:if test="${sourcesPresent == 'true'}">
<doc:deregisterReport name="Clover"/>
</j:if>
</goal>
<goal name="maven-clover-plugin:report">
<attainGoal name="clover:html-report"/>
</goal>
<!-- =================================================================== -->
<!-- Prepare for clover -->
<!-- =================================================================== -->
<goal name="clover:on">
<ant:taskdef resource="clovertasks"/>
<ant:typedef resource="clovertypes"/>
<j:set var="cloverDatabase"
value="${maven.clover.database.dir}/clover_coverage.db"/>
<clover-setup initstring="${cloverDatabase}"/>
<j:set var="cloverReportDirectory" value="${maven.docs.dest}/clover"/>
<maven:addPath id="maven.dependency.classpath" refid="clover.classpath"/>
<ant:mkdir dir="${maven.build.clover}"/>
<ant:mkdir dir="${maven.build.clover.classes}"/>
<ant:mkdir dir="${maven.clover.database.dir}"/>
<ant:mkdir dir="${cloverReportDirectory}"/>
</goal>
<!-- =================================================================== -->
<!-- C L O V E R R E P O R T S -->
<!-- =================================================================== -->
<goal name="clover"
description="Generate test coverage reports with Clover"
prereqs="clover:report"/>
<goal name="clover:test" prereqs="clover:on">
<!-- Make sure that the report is generated whether the tests pass or
not -->
<j:set var="ignoreTestFailureOld" value="${maven.test.failure.ignore}"/>
<j:set var="junitForkOld" value="${maven.junit.fork}"/>
<j:set var="maven.test.failure.ignore" scope="parent" value="true"/>
<j:set var="maven.junit.fork" scope="parent" value="true"/>
<echo>Setting Clover compiler</echo>
<!-- Transforming Ant path structure into a list of dirs that can be used
to define an Ant fileset. We're using <pathconvert> to automatically
separate dirs with a known delimiter independently of any platform -->
<ant:pathconvert property="compileSrcSetString" pathSep="||||"
refid="maven.compile.src.set"/>
<u:tokenize var="srcDirs" delim="||||">${compileSrcSetString}</u:tokenize>
<ant:pathconvert property="testSrcSetString" pathSep="||||"
refid="maven.test.compile.src.set"/>
<u:tokenize var="testDirs" delim="||||">${testSrcSetString}</u:tokenize>
<ant:clover-setup
initstring="${cloverDatabase}"
flushpolicy="interval"
flushinterval="500">
<j:forEach var="srcDir" items="${srcDirs}">
<ant:fileset dir="${srcDir}">
<ant:include name="**/*.java"/>
</ant:fileset>
</j:forEach>
<!-- Conditionally instrument test code -->
<j:if test="${context.getVariable('maven.clover.instrument.tests') == 'true'}">
<j:forEach var="testDir" items="${testDirs}">
<ant:fileset dir="${testDir}">
<ant:include name="**/*.java"/>
</ant:fileset>
</j:forEach>
</j:if>
</ant:clover-setup>
<echo>Now using primary build.compiler : ${build.compiler}</echo>
<j:set var="tmp" value="${maven.build.clover.classes}"/>
<j:set var="mavenBuildDestJavaOld"
value="${pom.getPluginContext('maven-java-plugin').getVariable('maven.build.dest')}"/>
${pom.getPluginContext('maven-java-plugin').setVariable('maven.build.dest',tmp)}
<j:set var="mavenBuildDestTestOld"
value="${pom.getPluginContext('maven-test-plugin').getVariable('maven.build.dest')}"/>
${pom.getPluginContext('maven-test-plugin').setVariable('maven.build.dest',tmp)}
<attainGoal name="test:test"/>
${pom.getPluginContext('maven-test-plugin').setVariable('maven.build.dest',mavenBuildDestTestOld)}
${pom.getPluginContext('maven-java-plugin').setVariable('maven.build.dest',mavenBuildDestJavaOld)}
${pom.getContext().removeVariable('build.compiler')}
<j:set var="maven.test.failure.ignore" scope="parent" value="${ignoreTestFailureOld}"/>
<j:set var="maven.junit.fork" scope="parent" value="${junitForkOld}"/>
</goal>
<!--
========================================================================
Generate test coverage reports. It decides what kind of reports should
be generated.
========================================================================
-->
<goal name="clover:report" prereqs="clover:test">
<!-- Skip reports if no coverage database has been created. -->
<u:file var="cloverDatabaseAsFile" name="${cloverDatabase}"/>
<j:choose>
<j:when test="${cloverDatabaseAsFile.exists()}">
<j:if test="${context.getVariable('maven.clover.report.xml') == 'true'}">
<attainGoal name="clover:xml-report-internal"/>
</j:if>
<j:if test="${context.getVariable('maven.clover.report.html') == 'true'}">
<attainGoal name="clover:html-report-internal"/>
</j:if>
<j:if test="${context.getVariable('maven.clover.report.swing') == 'true'}">
<attainGoal name="clover:swing-report-internal"/>
</j:if>
</j:when>
<j:otherwise>
<ant:echo>No Clover database found, skipping report generation</ant:echo>
</j:otherwise>
</j:choose>
</goal>
<!--
========================================================================
Generate XML test coverage report.
========================================================================
-->
<goal name="clover:xml-report-internal">
<ant:clover-report>
<current outfile="${maven.build.dir}/clover.xml"
title="${pom.name} - ${pom.currentVersion}">
<format type="xml" orderBy="${maven.clover.orderBy}"/>
</current>
</ant:clover-report>
</goal>
<goal
name="clover:xml-report"
description="Generate XML test coverage reports with Clover"
prereqs="clover:test,clover:xml-report-internal"/>
<!--
========================================================================
Generate HTML test coverage report.
========================================================================
-->
<goal name="clover:html-report-internal">
<ant:clover-report>
<current
outfile="${cloverReportDirectory}"
title="${pom.name} - ${pom.currentVersion}">
<format type="html" orderBy="${maven.clover.orderBy}"/>
</current>
</ant:clover-report>
</goal>
<goal
name="clover:html-report"
description="Generate HTML test coverage reports with Clover"
prereqs="clover:test,clover:html-report-internal"/>
<!--
========================================================================
Generate Swing test coverage report.
========================================================================
-->
<goal name="clover:swing-report-internal">
<ant:mkdir dir="${cloverReportDirectory}"/>
<ant:java classname="com.cortexeb.tools.clover.reporters.jfc.Viewer"
fork="yes">
<ant:arg line="${clover.initstring}"/>
<ant:classpath>
<ant:path refid="maven-classpath"/>
<ant:path refid="clover.classpath"/>
</ant:classpath>
</ant:java>
</goal>
<goal
name="clover:swing-report"
description="Generate Swing test coverage reports with Clover"
prereqs="clover:test,clover:swing-report-internal"/>
</project>