Skip to content

Instantly share code, notes, and snippets.

@yangboz yangboz/JAVA_PMD.xml
Created Oct 23, 2012

What would you like to do?
Ant xml example for JAVA code PMD.
<?xml version="1.0"?>
<project name="XXX Application Build with PMD" default="run"
Ant build sample for running
- PMD,
<!-- Change the paths to your individual installation directories -->
<property name="pmd.home.dir" location="${basedir}/tools/pmd/" />
<property name="lib.dir" location="${basedir}/map/lib" />
<property name="src.dir" location="${basedir}/map/app/" />
<property name="bin.dir" location="${basedir}/bin" />
<property name="htm.dir" location="${basedir}/html" />
<property name="report.dir" location="${basedir}/report" />
<property name="report.pmd.dir" location="${report.dir}/pmd" />
<!-- Task of clean -->
<target name="clean" description="Delete all result to start with a clean build.">
<delete dir="${report.pmd.dir}" />
<delete dir="${report.temp.dir}" />
<delete dir="${bin.dir}" />
<!-- Task of prepare report -->
<target name="" description="Prepares the reports folder">
<mkdir dir="${report.pmd.dir}" />
<!-- -->
<path id="pmd2.classpath">
<pathelement location="${build}" />
<fileset dir="${pmd.home.dir}/lib/">
<include name="*.jar" />
<!-- Task of PMD -->
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask"
classpathref="pmd2.classpath" />
<target name="report.pmd">
<mkdir dir="${report.pmd.dir}" />
<!-- <pmd rulesetfiles="${pmd.home.dir}/lib/rulesets/pmd-ruleset.xml"> -->
<formatter type="xml" toFile="${report.pmd.dir}/pmd_report.xml" />
<ruleset>rulesets/java/basic.xml</ruleset> <!-- references file in PMD's .jar -->
<fileset dir="${src.dir}">
<include name="**/*.java" />
<xslt in="${report.pmd.dir}/pmd_report.xml" style="${pmd.home.dir}/etc/xslt/pmd-report-per-class.xslt"
out="${report.pmd.dir}/pmd_report.html" />
<!-- -->
<target name="run" description="Run the build" depends="clean,,report.pmd">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.