And, to generate the CPD XML report, you could do something like this:
<target name="cpd">
<cpd minimumTokenCount="100" format="xml" outputFile="/target/cpd.xml">
<fileset dir="src/main/java" includes="**/*.java"/>
</cpd>
</target>
You can place this XML ruleset in your project classpath (for example, in src/main/resources for
a Maven project), or in a separate module (if you want to share the configuration between projects).
An example of how to configure Maven 2 to generate PMD and CPD reports using an exported XML
ruleset as shown here:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.5</version>
<configuration>
<!-- PMD options -->
<targetJdk>1.6</targetJdk>
<aggregate>true</aggregate>
<format>xml</format>
<rulesets>
<ruleset>/pmd-rules.xml</ruleset>
</rulesets>
<!-- CPD options -->
<minimumTokens>20</minimumTokens>
<ignoreIdentifiers>true</ignoreIdentifiers>
</configuration>
</plugin>
</plugins>
</reporting>
If you are using Maven 3, you would place the plugin definition in the
configuration section. This example also shows how to use a ruleset in another dependency (in this case
the pmd-rules.jar file):
<project>
...
<build>
...
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.0-beta-2</version>
<configuration>
<reportPlugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>