maven-plugins/pmd/plugin.jelly

68 lines
2.1 KiB
XML

<?xml version="1.0"?>
<project
xmlns:j="jelly:core"
xmlns:doc="doc">
<goal name="maven-pmd-plugin:register">
<j:if test="${sourcesPresent}">
<doc:registerReport
name="PMD"
link="pmd-report"
description="PMD Report."/>
</j:if>
</goal>
<!-- ================================================================== -->
<!-- P M D T A R G E T -->
<!-- ================================================================== -->
<goal name="pmd" description="Static Code Analyzer">
<!-- Only run PMD if it is enabled -->
<j:set var="enable" value="${maven.pmd.enable}"/>
<!-- Either am bloody dumb or this is the only way to make it work ?! -->
<j:if test="${enable.toString().equalsIgnoreCase('true')}">
<attainGoal name="maven-pmd-plugin:report"/>
</j:if>
</goal>
<goal name="maven-pmd-plugin:report"
description="Generate source code report with PMD">
<!-- Create the dirs if we start from a previously cleaned project -->
<mkdir dir="${maven.build.dir}"/>
<mkdir dir="${maven.docs.dest}"/>
<!-- Define a PMD task with the rulesets and all jars in the classpath -->
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask"/>
<!-- Run the PMD task - need a way to define the rulesets dynamically -->
<echo>Running the PMD task with ${maven.pmd.rulesetfiles} ...</echo>
<pmd rulesetfiles="${maven.pmd.rulesetfiles}">
<formatter type="xml" toFile="${maven.build.dir}/pmd-raw-report.xml"/>
<fileset dir="${basedir}/${pom.build.sourceDirectory}">
<include name="**/*.java"/>
</fileset>
</pmd>
<!-- Run DVSL to transform the report into XDOC -->
<echo>Converting the PMD report to XDOC ...</echo>
<doc:jsl
input="${maven.build.dir}/pmd-raw-report.xml"
output="pmd-report.xml"
stylesheet="${plugin.dir}/pmd.jsl"
omitXmlDeclaration="true"
outputMode="xml"
prettyPrint="true"
/>
</goal>
</project>