Permalink
Browse files

FLUME-291: Integrate PMD optionally into the build (ant pmd).

  • Loading branch information...
1 parent e406592 commit c88a5a5040d6ea8425049441d8141c273a6024e1 @waywardmonkeys waywardmonkeys committed with jmhsieh Oct 26, 2010
Showing with 49 additions and 2 deletions.
  1. +2 −1 .gitignore
  2. +20 −1 build.xml
  3. +2 −0 ivy.xml
  4. +25 −0 pmd.xml
View
@@ -17,4 +17,5 @@ lib/ivy-*.jar
src/avro-gen-java
src/avro/*.avpr
docs/
-.eclipse
+.eclipse
+pmd_report.html
View
@@ -217,6 +217,11 @@ to call at top-level: ant deploy-contrib compile-core-test
pattern="${ivy.tools.lib}/[artifact]-[revision].[ext]"/>
</target>
+ <target name="ivy-retrieve-pmd" depends="init,ivy-init">
+ <ivy:retrieve type="jar" conf="pmd"
+ pattern="${ivy.tools.lib}/[artifact]-[revision].[ext]"/>
+ </target>
+
<target name="ivy-retrieve-coverage" depends="init,ivy-init">
<ivy:retrieve type="jar" conf="coverage"
pattern="${ivy.tools.lib}/[artifact]-[revision].[ext]"/>
@@ -229,7 +234,7 @@ to call at top-level: ant deploy-contrib compile-core-test
</target>
<target name="ivy-retrieve-all"
- depends="ivy-retrieve,ivy-retrieve-test,ivy-retrieve-findbugs,ivy-retrieve-coverage,ivy-retrieve-releaseaudit" />
+ depends="ivy-retrieve,ivy-retrieve-test,ivy-retrieve-findbugs,ivy-retrieve-pmd,ivy-retrieve-coverage,ivy-retrieve-releaseaudit" />
<target name="compile-aho" depends="init,ivy-retrieve-test">
<javac
@@ -492,6 +497,20 @@ to call at top-level: ant deploy-contrib compile-core-test
</findbugs>
</target>
+ <target name="pmd" depends="ivy-retrieve-pmd, jar, jar-test">
+ <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="tools.classpath"/>
+ <pmd shortFilenames="true">
+ <ruleset>pmd.xml</ruleset>
+ <formatter type="html" toFile="pmd_report.html"/>
+ <fileset dir="${basedir}/src/java">
+ <include name="**/*.java"/>
+ </fileset>
+ <fileset dir="${basedir}/src/javatest">
+ <include name="**/*.java"/>
+ </fileset>
+ </pmd>
+ </target>
+
<target name="instrument" depends="compile-core, compile-core-test,ivy-retrieve-coverage">
<taskdef classpath="${ivy.tools.lib}/cobertura-1.9.4.1.jar" resource="tasks.properties">
<classpath>
View
@@ -29,6 +29,7 @@
<conf name="default"/>
<conf name="test"/>
<conf name="findbugs" visibility="private"/>
+ <conf name="pmd" visibility="private"/>
<conf name="coverage" visibility="private"/>
<conf name="releaseaudit" visibility="private" description="Artifacts required for releaseaudit target"/>
</configurations>
@@ -46,6 +47,7 @@
rev="1.3.9" conf="findbugs->default" />
<dependency org="com.google.code.findbugs" name="findbugs-ant"
rev="1.3.9" conf="findbugs->default" />
+ <dependency org="pmd" name="pmd" rev="4.2.5" conf="pmd->default"/>
<dependency org="net.sourceforge.cobertura" name="cobertura"
rev="1.9.4.1" conf="coverage->default" transitive="false"/>
View
25 pmd.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<ruleset name="Custom ruleset"
+ xmlns="http://pmd.sf.net/ruleset/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
+ xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
+ <description>
+ This ruleset provides some standard checks for Flume.
+ </description>
+ <rule ref="rulesets/basic.xml">
+ <exclude name="AvoidUsingHardCodedIP"/>
+ </rule>
+ <rule ref="rulesets/imports.xml">
+ <exclude name="TooManyStaticImports"/>
+ </rule>
+ <rule ref="rulesets/junit.xml">
+ <exclude name="JUnitAssertionsShouldIncludeMessage"/>
+ <exclude name="JUnitTestsShouldIncludeAssert"/>
+ </rule>
+ <rule ref="rulesets/logging-java.xml"/>
+ <rule ref="rulesets/strings.xml">
+ <exclude name="AvoidDuplicateLiterals"/>
+ </rule>
+ <rule ref="rulesets/unusedcode.xml"/>
+</ruleset>

0 comments on commit c88a5a5

Please sign in to comment.