Index: lucene/common-build.xml
===================================================================
--- lucene/common-build.xml	(revision 1329052)
+++ lucene/common-build.xml	(working copy)
@@ -1215,6 +1215,27 @@
     </sequential>
   </target>
 
+  <target name="pmd-typedef" depends="ivy-availability-check,ivy-fail">
+    <ivy:cachepath pathid="pmd.classpath" organisation="pmd" module="pmd" revision="4.3" inline="true" log="download-only" type="jar" />
+    <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="pmd.classpath"/>
+  </target>
+
+  <target name="pmd" depends="pmd-typedef">
+    <sequential>
+      <echo message="PMD analyzing ${name}"/>
+      <mkdir dir="${common.build.dir}/pmd"/>
+      <pmd shortFilenames="true" targetjdk="1.6">
+        <ruleset>rulesets/design.xml</ruleset>
+        <ruleset>rulesets/basic.xml</ruleset>
+        <formatter type="html" toFile="${common.build.dir}/pmd/${name}.html"/>
+        <fileset dir="${src.dir}">
+          <include name="**/*.java"/>
+          <exclude name="${pmd.excludes}"/>
+        </fileset>
+      </pmd>
+    </sequential>
+  </target>
+
   <!--+
       | M A C R O S
       +-->
Index: lucene/build.xml
===================================================================
--- lucene/build.xml	(revision 1329052)
+++ lucene/build.xml	(working copy)
@@ -28,7 +28,7 @@
 
   <patternset id="binary.build.dist.patterns"
               includes="docs/,**/*.jar,**/*.war"
-              excludes="poms/**,**/*-src.jar,**/*-javadoc.jar"
+              excludes="pmd/**,poms/**,**/*-src.jar,**/*-javadoc.jar"
   />
   <patternset id="binary.root.dist.patterns"
               includes="LICENSE.txt,NOTICE.txt,README.txt,
@@ -230,6 +230,15 @@
     </sequential>
   </target>
 
+  <target name="pmd">
+     <sequential>
+       <ant dir="core" target="pmd" inheritall="false"/>
+       <ant dir="test-framework" target="pmd" inheritall="false"/>
+       <ant dir="tools" target="pmd" inheritall="false"/>
+       <modules-crawl target="pmd" failonerror="true"/>
+    </sequential>
+  </target>
+
   <!-- ================================================================== -->
   <!-- D I S T R I B U T I O N                                            -->
   <!-- ================================================================== -->
Index: lucene/analysis/build.xml
===================================================================
--- lucene/analysis/build.xml	(revision 1329049)
+++ lucene/analysis/build.xml	(working copy)
@@ -118,5 +118,9 @@
   <target name="rat-sources">
     <forall-analyzers target="rat-sources"/>
   </target>
+
+  <target name="pmd">
+    <forall-analyzers target="pmd"/>
+  </target>
 	
 </project>
