1. Download PMD zip file (I use 4.2.5), upZip it. There are some folders: bin, docs, etc, java14, lib..
2. The ant build file, e.g.
<?xml version="1.0" encoding="UTF-8"?>
<project name="pmd" default="pmd" basedir=".">
<path id="pmd.classpath">
<fileset dir="C:\Tools\hudson\jobs\CheckDuplicateCode\pmd-4.2.5\lib">
<include name="*.jar"/>
</fileset>
</path>
<target name="cpd">
<taskdef name="cpd" classname="net.sourceforge.pmd.cpd.CPDTask" classpathref="pmd.classpath"/>
<cpd minimumTokenCount="100" format="xml" outputFile="workspace\cpd.xml">
<fileset dir="\src">
<include name="**/*.java"/>
</fileset>
</cpd>
</target>
</project>
--The first "fileset" "dir" is the lib path in the PMD folder.
--The output file is the output report file.
--If you want hudson to analyze the output file, remember to sef format="xml"
--The second "fileset" "dir" is the soucecode path, to set which code you want to analyze.
3. Then you can use the ant build file in your hudson jobs.
浙公网安备 33010602011771号