brett 2004/02/29 17:50:22
Modified: pmd plugin.jelly plugin.properties
pmd/xdocs changes.xml properties.xml
Log:
PR: MPPMD-5
Add CPD report patch
Revision Changes Path
1.11 +64 -1 maven-plugins/pmd/plugin.jelly
Index: plugin.jelly
===================================================================
RCS file: /home/cvs/maven-plugins/pmd/plugin.jelly,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- plugin.jelly 20 Nov 2003 15:35:16 -0000 1.10
+++ plugin.jelly 1 Mar 2004 01:50:22 -0000 1.11
@@ -19,6 +19,11 @@
pluginName="pmd"
description="Verification of coding rules."
link="pmd-report"/>
+ <doc:registerReport
+ name="CPD Report"
+ pluginName=""
+ description="Detection of copy-paste code."
+ link="cpd-report"/>
</j:if>
</goal>
@@ -30,6 +35,7 @@
<goal name="maven-pmd-plugin:deregister">
<j:if test="${sourcesPresent}">
<doc:deregisterReport name="PMD Report"/>
+ <doc:deregisterReport name="CPD Report"/>
</j:if>
</goal>
@@ -118,6 +124,63 @@
prettyPrint="true"
/>
+ <!-- Generate CPD report if it is enabled -->
+ <j:set var="enable" value="${maven.pmd.cpd.enable}"/>
+
+ <j:if test="${enable == 'true'}">
+ <attainGoal name="pmd:cpd-report"/>
+ </j:if>
</goal>
-
+
+ <!--
+ ========================================================================
+ Generate the CPD report.
+ ========================================================================
+ -->
+ <goal name="pmd:cpd-report"
+ description="Generate duplicate source code report with CPD">
+
+ <!-- Define a CPD task from the PMD jar -->
+ <taskdef name="cpd"
+ classpath="${plugin.getDependencyPath('pmd:pmd')}"
+ classname="net.sourceforge.pmd.cpd.CPDTask"/>
+
+ <!-- Run the CPD task -->
+ <echo>Running the CPD task with minimumTokenCount =
${maven.pmd.cpd.minimumtokencount} ...</echo>
+
+ <cpd minimumTokenCount="${maven.pmd.cpd.minimumtokencount}"
+ outputFile="${maven.build.dir}/cpd-raw-report.txt">
+ <!-- cut and paste from pmd:report -->
+ <fileset dir="${pom.build.sourceDirectory}"
+ includes="${maven.pmd.includes}"
+ excludes="${maven.pmd.excludes}">
+
+ <!-- FIXME: This is a bad cut and paste -->
+ <!-- handle source modifications -->
+ <j:forEach var="sm" items="${pom.build.sourceModifications}">
+ <available property="classPresent" classname="${sm.className}"/>
+ <j:if test="${classPresent != 'true'}">
+ <j:forEach var="exclude" items="${sm.excludes}">
+ <exclude name="${exclude}"/>
+ </j:forEach>
+ <j:forEach var="include" items="${sm.includes}">
+ <include name="${include}"/>
+ </j:forEach>
+ </j:if>
+ </j:forEach>
+ </fileset>
+ </cpd>
+
+ <!-- Convert raw text report into XDOC -->
+
+ <j:set var="genDocs" value="${maven.gen.docs}" />
+ <doc:text-xdoc
+ title="CPD Report"
+ section="CPD Report"
+ inputFile="${maven.build.dir}/cpd-raw-report.txt"
+ output="${genDocs}/cpd-report.xml"
+ />
+
+ </goal>
+
</project>
1.5 +8 -0 maven-plugins/pmd/plugin.properties
Index: plugin.properties
===================================================================
RCS file: /home/cvs/maven-plugins/pmd/plugin.properties,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- plugin.properties 22 Jul 2003 16:13:27 -0000 1.4
+++ plugin.properties 1 Mar 2004 01:50:22 -0000 1.5
@@ -15,3 +15,11 @@
maven.pmd.includes = **/*.java
maven.pmd.excludes =
+
+# enable/disable CPD
+
+maven.pmd.cpd.enable = false
+
+# minimum length of token sequences considered equal
+
+maven.pmd.cpd.minimumtokencount = 100
1.16 +3 -0 maven-plugins/pmd/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/maven-plugins/pmd/xdocs/changes.xml,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- changes.xml 20 Nov 2003 15:35:16 -0000 1.15
+++ changes.xml 1 Mar 2004 01:50:22 -0000 1.16
@@ -15,6 +15,9 @@
<action dev="dion" type="update">
Apply MAVEN-1008. Allow for custom rulesets in the classpath.
</action>
+ <action dev="brett" type="add" issue="MPPMD-5" due-to="Morten Kvistgaard">
+ Apply MPPMD-5. Add support for CPD report.
+ </action>
</release>
<release version="1.2" date="2003-09-20">
1.3 +15 -0 maven-plugins/pmd/xdocs/properties.xml
Index: properties.xml
===================================================================
RCS file: /home/cvs/maven-plugins/pmd/xdocs/properties.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- properties.xml 22 Jul 2003 16:13:26 -0000 1.2
+++ properties.xml 1 Mar 2004 01:50:22 -0000 1.3
@@ -54,6 +54,21 @@
exclude any files.
</td>
</tr>
+ <tr>
+ <td>maven.pmd.cpd.enable</td>
+ <td>Yes</td>
+ <td>
+ Enable/disable the CPD report. Defaults to "false".
+ </td>
+ </tr>
+ <tr>
+ <td>maven.pmd.cpd.minimumtokencount</td>
+ <td>Yes</td>
+ <td>
+ Specifies the minimal number required to consider two sequences of
+ tokens identical. Defaults to "100".
+ </td>
+ </tr>
</table>
</section>
</body>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]