- Added a quick usage guide in the documentation.

- Fixed issue where <code>clover:report</code> was not calling <code>clover:on</code> leading to an error when generating the reports.
- Ensure that <code>clover:init</code>, <code>clover:on</code> and <code>clover:off</code> can only be called once. For example calling <code>clover:on</code> twice in a row will execute it only once.
- The <code>clover:*-report</code> goals do not call <code>clover:test</code> anymore. They only generates Clover reports. This is now aligned with the <code>clover:report</code> behavior. To run the full thing, execute the <code>clover</code> goal or add the Clover report to your project's POM.
- Added a <code>maven.clover.multiproject</code> property that should be set to true in your master project (if you're using a multiproject setup). Setting it to true will make the <code>clover</code> goal and the <code>maven-clover-plugin</code> report in your POM execute on all subprojects (they'll call the new <code>clover:multiproject</code> goal).
- New <code>clover:multiproject</code> goal to run Clover on a multiproject setup.
- New <code>clover:merge</code> goal that creates a new Clover database by merging several other databases specified using the <code>maven.clover.merge.databases</code> property (which defaults to <code>**/clover_coverage.db</code>).


git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@169652 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
vmassol committed 2005-05-11 16:28:26 +00:00
1 parent b6d3b9eebc
commit 98d793400e
15 files changed
+492 -33

No files matched your search

+122 -31
View File
@@ -19,6 +19,7 @@
-->
<project
xmlns:multiproject="multiproject"
xmlns:j="jelly:core"
xmlns:ant="jelly:ant"
xmlns:maven="jelly:maven"
@@ -32,7 +33,7 @@
Initialize the Clover plugin.
========================================================================
-->
<goal name="clover:init">
<goal name="clover:init-internal">
<!-- Create an Ant <path> id that contains the Clover jar. If the user has
defined the maven.clover.jar property then this path will contain his
@@ -79,6 +80,15 @@
</j:if>
<u:file var="historyDirAsFile" name="${maven.clover.history.dir}"/>
</goal>
<goal name="clover:init">
<!-- Ensure intialization is called only once -->
<j:if test="${!cloverInitialized}">
<attainGoal name="clover:init-internal"/>
<j:set var="cloverInitialized" value="true"/>
</j:if>
</goal>
@@ -87,9 +97,21 @@
Generate test coverage reports with Clover.
========================================================================
-->
<goal name="clover"
description="Generate test coverage reports with Clover"
prereqs="clover:test,clover:report"/>
<goal name="clover" description="Generate test coverage reports with Clover">
<!-- Is it a multiproject setup? -->
<!-- TODO: Find a way to call clover:init only once below -->
<j:choose>
<j:when test="${maven.clover.multiproject}">
<attainGoal name="clover:multiproject"/>
</j:when>
<j:otherwise>
<attainGoal name="clover:test"/>
</j:otherwise>
</j:choose>
<attainGoal name="clover:report"/>
</goal>
<!--
========================================================================
@@ -102,8 +124,7 @@
need to call clover:off to reset them as they were initially.
========================================================================
-->
<goal name="clover:on" prereqs="clover:init"
description="Activates Clover">
<goal name="clover:on-internal" prereqs="clover:init">
<!-- Save properties so that they can be reset afterwards -->
<maven:get var="ignoreTestFailureOld" plugin="maven-test-plugin"
@@ -183,6 +204,16 @@
<j:set var="mavenBuildDestOld" value="${context.parent.getVariable('maven.build.dest')}"/>
<j:set var="maven.build.dest" value="${maven.clover.build.classes}" scope="parent" />
</goal>
<goal name="clover:on" prereqs="clover:init"
description="Activates Clover">
<!-- Ensure clover:on is only called once -->
<j:if test="${!isCloverOn}">
<attainGoal name="clover:on-internal"/>
<j:set var="isCloverOn" value="true"/>
</j:if>
</goal>
<!--
@@ -191,7 +222,7 @@
the call to clover:on.
========================================================================
-->
<goal name="clover:off" description="Deactivates Clover">
<goal name="clover:off-internal">
<j:set var="maven.build.dest" value="${mavenBuildDestOld}" scope="parent" />
${context.removeVariable('build.compiler')}
@@ -203,6 +234,15 @@
<maven:set plugin="maven-test-plugin" property="maven.junit.fork"
value="${junitForkOld}"/>
</goal>
<goal name="clover:off" description="Deactivates Clover">
<!-- Ensure clover:off is only called once -->
<j:if test="${isCloverOn}">
<attainGoal name="clover:off-internal"/>
<j:set var="isCloverOn" value="false"/>
</j:if>
</goal>
<!--
@@ -273,18 +313,18 @@
<j:when test="${cloverDatabaseAsFile.exists()}">
<j:if test="${context.getVariable('maven.clover.report.xml') == 'true'}">
<attainGoal name="clover:xml-report-internal"/>
<attainGoal name="clover:xml-report"/>
</j:if>
<j:if test="${context.getVariable('maven.clover.report.html') == 'true'}">
<attainGoal name="clover:html-report-internal"/>
<attainGoal name="clover:html-report"/>
</j:if>
<j:if test="${context.getVariable('maven.clover.report.swing') == 'true'}">
<attainGoal name="clover:swing-report-internal"/>
<attainGoal name="clover:swing-report"/>
</j:if>
<j:if test="${context.getVariable('maven.clover.report.pdf') == 'true'}">
<attainGoal name="clover:pdf-report-internal"/>
<attainGoal name="clover:pdf-report"/>
</j:if>
</j:when>
<j:otherwise>
<ant:echo>No Clover database found, skipping report generation</ant:echo>
@@ -298,7 +338,11 @@
Generate XML test coverage report.
========================================================================
-->
<goal name="clover:xml-report-internal">
<goal name="clover:xml-report"
description="Generate XML test coverage reports with Clover">
<attainGoal name="clover:on"/>
<ant:clover-report>
<ant:current outfile="${maven.build.dir}/clover.xml" alwaysReport="true"
title="${pom.name} - ${pom.currentVersion}">
@@ -313,17 +357,20 @@
</ant:format>
</ant:current>
</ant:clover-report>
<attainGoal name="clover:off"/>
</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">
<goal name="clover:html-report"
description="Generate HTML test coverage reports with Clover">
<attainGoal name="clover:on"/>
<j:set var="cloverReportDirectory" value="${maven.docs.dest}/clover"/>
<ant:mkdir dir="${cloverReportDirectory}"/>
@@ -359,29 +406,33 @@
</ant:clover-report>
<attainGoal name="clover:off"/>
</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:clover-view initString="${clover.initstring}"/>
</goal>
<goal name="clover:swing-report"
description="Generate Swing test coverage reports with Clover"
prereqs="clover:test,clover:swing-report-internal"/>
description="Generate Swing test coverage reports with Clover">
<attainGoal name="clover:on"/>
<ant:clover-view/>
<attainGoal name="clover:off"/>
</goal>
<!--
========================================================================
Generate PDF test coverage report.
========================================================================
-->
<goal name="clover:pdf-report-internal">
<goal name="clover:pdf-report"
description="Generate PDF test coverage reports with Clover">
<attainGoal name="clover:on"/>
<j:set var="cloverReportDirectory" value="${maven.docs.dest}/clover"/>
<j:set var="cloverPDFReportFile" value="${cloverReportDirectory}/clover.pdf"/>
@@ -417,11 +468,10 @@
</j:if>
</ant:clover-report>
<attainGoal name="clover:off"/>
</goal>
<goal name="clover:pdf-report"
description="Generate PDF test coverage reports with Clover"
prereqs="clover:test,clover:pdf-report-internal"/>
<!--
========================================================================
@@ -430,7 +480,9 @@
-->
<goal name="maven-clover-plugin:register">
<j:if test="${unitTestSourcesPresent == 'true'}">
<j:if test="${unitTestSourcesPresent == 'true'
|| context.getVariable('maven.clover.multiproject') == 'true'}">
<doc:registerReport
name="Clover"
pluginName="maven-clover-plugin"
@@ -459,7 +511,8 @@
-->
<goal name="maven-clover-plugin:deregister">
<j:if test="${unitTestSourcesPresent == 'true'}">
<j:if test="${unitTestSourcesPresent == 'true'
|| context.getVariable('maven.clover.multiproject') == 'true'}">
<doc:deregisterReport name="Clover"/>
@@ -534,4 +587,42 @@
</goal>
<!--
========================================================================
Merge different Clover databases. This goal is meant to be used in
a top level master project.
========================================================================
-->
<goal name="clover:merge" prereqs="clover:init"
description="Merge Clover databases">
<ant:clover-merge initString="${maven.clover.database}">
<ant:cloverDbSet dir=".">
<ant:include name="${maven.clover.merge.databases}"/>
</ant:cloverDbSet>
</ant:clover-merge>
</goal>
<!--
========================================================================
Runs Clover on a multiproject and merge the Clover databases.This
goal does not generate a report; call clover:report for that or add
Clover as a report in your POM.
========================================================================
-->
<goal name="clover:multiproject" description="Run Clover on a multiproject">
<!-- TODO: Shouldn't be required as we're using maven:set but it doesn't
work if it's not there! -->
<multiproject:dependency-handle />
<maven:set plugin="maven-multiproject-plugin" property="goal"
value="clover:test"/>
<attainGoal name="multiproject:goal"/>
<attainGoal name="clover:merge"/>
</goal>
</project>
+9
View File
@@ -57,6 +57,12 @@ maven.clover.report.pdf = false
# based on an existing Clover database.
maven.clover.execute.during.report = true
# Specify whether the current project is a master project in a multiproject
# setup or not. Set it to true for your master project so that adding
# the maven-clover-plugin report to your POM will call the clover:multiproject
# goal (same for the clover goal).
maven.clover.multiproject = false
# List of files to include/exclude from Cloverification
maven.clover.includes = **/*.java
maven.clover.excludes =
@@ -65,6 +71,9 @@ maven.clover.excludes =
# history point data so that they are not erased, point this directory to
# a safe place that will not be deleted by a "maven clean".
maven.clover.history.dir = ${maven.clover.build}/history
# List of databases to include in the merge when using the clover:merge goal
maven.clover.merge.databases = **/clover_coverage.db
# Test coverage % under which the build will fail when clover:check is called.
# Set it to an empty value if you wish to only use the per-package definitions.
@@ -0,0 +1,41 @@
<!--
/*
* Copyright 2005 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 default="testPlugin"
xmlns:assert="assert">
<goal name="testPlugin" prereqs="testDirectCall,testCallByReport"/>
<goal name="testDirectCall" prereqs="clean,multiproject:clean">
<attainGoal name="clover:multiproject"/>
<attainGoal name="clover:xml-report"/>
<assert:assertFileContains file="${maven.build.dir}/clover.xml" match="Simple1.java"/>
<assert:assertFileContains file="${maven.build.dir}/clover.xml" match="Simple2.java"/>
</goal>
<goal name="testCallByReport" prereqs="clean,multiproject:clean">
<attainGoal name="site"/>
<assert:assertFileExists file="${maven.docs.dest}/clover/index.html"/>
</goal>
</project>
@@ -0,0 +1,17 @@
# -------------------------------------------------------------------
# Copyright 2005 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.
# -------------------------------------------------------------------
maven.clover.multiproject = true
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/*
* Copyright 2005 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>
<extend>${basedir}/../project.xml</extend>
<id>testMultiproject</id>
<name>testMultiproject</name>
<reports>
<report>maven-clover-plugin</report>
</reports>
</project>
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/*
* Copyright 2005 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>
<extend>${basedir}/../project.xml</extend>
<id>testMultiproject-subproject1</id>
<name>testMultiproject-subproject1</name>
<build>
<sourceDirectory>src/main</sourceDirectory>
<unitTestSourceDirectory>src/test</unitTestSourceDirectory>
<unitTest>
<includes>
<include>**/*Test.java</include>
</includes>
</unitTest>
</build>
</project>
@@ -0,0 +1,25 @@
package org.apache.maven.clover.test;
/* ====================================================================
* Copyright 2005 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.
* ====================================================================
*/
public class Simple1
{
public void someMethod1()
{
}
}
@@ -0,0 +1,29 @@
package org.apache.maven.clover.test;
/* ====================================================================
* Copyright 2005 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.
* ====================================================================
*/
import junit.framework.TestCase;
public class Simple1Test extends TestCase
{
public void testSomeMethod1()
{
Simple1 simple = new Simple1();
simple.someMethod1();
}
}
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/*
* Copyright 2005 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>
<extend>${basedir}/../project.xml</extend>
<id>testMultiproject-subproject2</id>
<name>testMultiproject-subproject2</name>
<build>
<sourceDirectory>src/main</sourceDirectory>
<unitTestSourceDirectory>src/test</unitTestSourceDirectory>
<unitTest>
<includes>
<include>**/*Test.java</include>
</includes>
</unitTest>
</build>
</project>
@@ -0,0 +1,25 @@
package org.apache.maven.clover.test;
/* ====================================================================
* Copyright 2005 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.
* ====================================================================
*/
public class Simple2
{
public void someMethod2()
{
}
}
@@ -0,0 +1,29 @@
package org.apache.maven.clover.test;
/* ====================================================================
* Copyright 2005 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.
* ====================================================================
*/
import junit.framework.TestCase;
public class Simple2Test extends TestCase
{
public void testSomeMethod2()
{
Simple2 simple = new Simple2();
simple.someMethod2();
}
}
+38
View File
@@ -26,6 +26,44 @@
</properties>
<body>
<release version="1.9-SNAPSHOT" date="in SVN">
<action dev="vmassol" type="add">
Added a quick usage guide in the documentation.
</action>
<action dev="vmassol" type="fix">
Fixed issue where <code>clover:report</code> was not calling
<code>clover:on</code> leading to an error when generating the
reports.
</action>
<action dev="vmassol" type="update">
Ensure that <code>clover:init</code>, <code>clover:on</code>
and <code>clover:off</code> can only be called once. For example
calling <code>clover:on</code> twice in a row will execute it only
once.
</action>
<action dev="vmassol" type="update">
The <code>clover:*-report</code> goals do not call
<code>clover:test</code> anymore. They only generates Clover reports.
This is now aligned with the <code>clover:report</code> behavior.
To run the full thing, execute the <code>clover</code> goal or
add the Clover report to your project's POM.
</action>
<action dev="vmassol" type="add">
Added a <code>maven.clover.multiproject</code> property that should be
set to true in your master project (if you're using a multiproject setup).
Setting it to true will make the <code>clover</code> goal and the
<code>maven-clover-plugin</code> report in your POM execute on all
subprojects (they'll call the new <code>clover:multiproject</code> goal).
</action>
<action dev="vmassol" type="add">
New <code>clover:multiproject</code> goal to run Clover on a
multiproject setup.
</action>
<action dev="vmassol" type="add">
New <code>clover:merge</code> goal that creates a new Clover
database by merging several other databases specified using
the <code>maven.clover.merge.databases</code> property (which
defaults to <code>**/clover_coverage.db</code>).
</action>
<action dev="vmassol" type="fix">
Fixed issue with Clover task and type definitions not using an
explicit classpath which apparently breaks under Maven 1.1.
+17 -1
View File
@@ -65,7 +65,7 @@
<description>
Generate Clover test coverage reports with Clover. There are 3
possible reports: HTML, XML or Swing. Whether a report is generated
is controller by the <code>maven.clover.report.[report name]</code>
is controlled by the <code>maven.clover.report.[report name]</code>
<a href="properties.html">properties</a>. The generated reports show
exactly what lines of your code were exercised by your tests.
</description>
@@ -117,6 +117,22 @@
history reports when the <code>clover:report</code> goal is called.
</description>
</goal>
<goal>
<name>clover:merge</name>
<description>
Merges several Clover databases into one. This goal is meant to be
called in the top level master project (multiproject). It is called
automatically by the <code>clover:multiproject</code> goal.
</description>
</goal>
<goal>
<name>clover:multiproject</name>
<description>
Runs Clover on a multiproject and merge the Clover databases.This
goal does not generate a report; call clover:report for that or add
Clover as a report in your POM.
</description>
</goal>
</goals>
</body>
</document>
+33 -1
View File
@@ -2,7 +2,7 @@
<!--
/*
* Copyright 2001-2004 The Apache Software Foundation.
* Copyright 2001-2005 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.
@@ -38,5 +38,37 @@
need to get a license for the Clover jar before using this plugin.
</p>
</section>
<section name="Using the Clover plugin">
<p>
There are 3 possible ways of running the plugin:
</p>
<ul>
<li>
<b>All in one</b>: You'll either call the <code>clover</code> goal or
add the <code>maven-clover-plugin</code> report to the <code>reports</code>
section in your POM. This will instrument your source code, run your
project's tests on the cloverified code and generate Clover reports. Note that
if you're in a multiproject setup, you must set the
<code>maven.clover.multiproject</code> property to <code>true</code> in your master
project. Doing so will automatically gather Clover data from all your subprojects
and aggregate them in a master project report.
</li>
<li>
<b>In 2 steps</b>: You'll call <code>clover:test</code> which will
instrument your source code and run your project's tests on the cloverified code.
Alternatively you can call <code>clover:multiproject</code> to run the
<code>clover:test</code> goal on all your subprojects in you're in a multiproject
setup. You'll then need to call <code>clover:report</code> to generate the reports.
</li>
<li>
<b>In 3 steps</b>: You'll call <code>clover:on</code> followed by whatever other
goal you wish (for example <code>maven clover:on war</code>.) This will instrument
your source code. Then you'll run any goal that tests your artifacts. For example
in the case of a WAR you can use HttpUnit/HtmlUnit to run functional tests. The
test of your artifact will fill the Clover database with data. Finally you'll run
<code>clover:report</code> to generate the reports.
</li>
</ul>
</section>
</body>
</document>
+11
View File
@@ -270,6 +270,17 @@
${maven.clover.build}/history
</td>
</tr>
<tr>
<td>maven.clover.merge.databases</td>
<td>Yes</td>
<td>
List of databases to include in the merge when using the
<code>clover:merge</code> goal.
</td>
<td>
**/clover_coverage.db
</td>
</tr>
</table>
</section>
</body>