[ant] Improve documentation

Refs #4658
This commit is contained in:
Andreas Dangel
2023-08-31 14:42:53 +02:00
parent 056b339eb4
commit 6e61b9f2a8
4 changed files with 52 additions and 17 deletions

View File

@ -333,8 +333,14 @@ For details, see [CPD Report Formats](pmd_userdocs_cpd_report_formats.html).
Andy Glover wrote an Ant task for CPD; here's how to use it:
```xml
<path id="pmd.classpath">
<fileset dir="/home/joe/pmd-bin-{{site.pmd.version}}/lib">
<include name="*.jar"/>
</fileset>
</path>
<taskdef name="cpd" classname="net.sourceforge.pmd.ant.CPDTask" classpathref="pmd.classpath" />
<target name="cpd">
<taskdef name="cpd" classname="net.sourceforge.pmd.ant.CPDTask" />
<cpd minimumTokenCount="100" outputFile="/home/tom/cpd.txt">
<fileset dir="/home/tom/tmp/ant">
<include name="**/*.java"/>

View File

@ -181,7 +181,6 @@ automatically and the latest language version is used.
`ruleset` nested element - another way to specify rulesets. You can specify multiple elements. Here's an example:
<target name="pmd">
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask"/>
<pmd>
<ruleset>rulesets/java/quickstart.xml</ruleset>
<ruleset>config/my-ruleset.xml</ruleset>
@ -373,7 +372,6 @@ You can run pmd then with `ant pmd`.
An HTML report with the "linkPrefix" and "linePrefix" properties:
<target name="pmd">
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask"/>
<pmd rulesetfiles="rulesets/java/quickstart.xml">
<formatter type="html" toFile="pmd_report.html">
<param name="linkPrefix" value="https://maven.apache.org/plugins/maven-pmd-plugin/xref/"/>

View File

@ -40,20 +40,26 @@ import net.sourceforge.pmd.lang.LanguageRegistry;
*
* <p>Runs the CPD utility via ant. The ant task looks like this:</p>
*
* <pre>
* &lt;project name="CPDProj" default="main" basedir="."&gt;
* &lt;taskdef name="cpd" classname="net.sourceforge.pmd.cpd.CPDTask" /&gt;
* &lt;target name="main"&gt;
* &lt;cpd encoding="UTF-16LE" language="java" ignoreIdentifiers="true"
* ignoreLiterals="true" ignoreAnnotations="true" minimumTokenCount="100"
* outputFile="c:\cpdrun.txt"&gt;
* &lt;fileset dir="/path/to/my/src"&gt;
* &lt;include name="*.java"/&gt;
* &lt;/fileset&gt;
* &lt;/cpd&gt;
* &lt;/target&gt;
* &lt;/project&gt;
* </pre>
* <pre>{@code
* <project name="CPDProject" default="main" basedir=".">
* <path id="pmd.classpath">
* <fileset dir="/home/joe/pmd-bin-VERSION/lib">
* <include name="*.jar"/>
* </fileset>
* </path>
* <taskdef name="cpd" classname="net.sourceforge.pmd.ant.CPDTask" classpathref="pmd.classpath" />
*
* <target name="main">
* <cpd encoding="UTF-16LE" language="java" ignoreIdentifiers="true"
* ignoreLiterals="true" ignoreAnnotations="true" minimumTokenCount="100"
* outputFile="c:\cpdrun.txt">
* <fileset dir="/path/to/my/src">
* <include name="*.java"/>
* </fileset>
* </cpd>
* </target>
* </project>
* }</pre>
*
* <p>Required: minimumTokenCount, outputFile, and at least one file</p>
*/

View File

@ -24,6 +24,31 @@ import net.sourceforge.pmd.ant.internal.PMDTaskImpl;
/**
* PMD Ant task. Setters of this class are interpreted by Ant as properties
* settable in the XML. This is therefore published API.
*
* <p>Runs PMD analysis via ant. The ant task looks like this:</p>
*
* <pre>{@code
* <project name="PMDProject" default="main" basedir=".">
* <path id="pmd.classpath">
* <fileset dir="/home/joe/pmd-bin-VERSION/lib">
* <include name="*.jar"/>
* </fileset>
* </path>
* <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="pmd.classpath" />
*
* <target name="main">
* <pmd>
* <ruleset>rulesets/java/quickstart.xml</ruleset>
* <ruleset>config/my-ruleset.xml</ruleset>
* <fileset dir="/usr/local/j2sdk1.4.1_01/src/">
* <include name="java/lang/*.java"/>
* </fileset>
* </pmd>
* </target>
* </project>
* }</pre>
*
* <p>Required: rulesetfiles/ruleset, fileset</p>
*/
public class PMDTask extends Task {