ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Karr, David" <david.k...@wamu.net>
Subject How to accumulate a list of files for pmd instead of running pmd on each one
Date Wed, 07 Nov 2007 18:15:05 GMT
JDK 1.4.2, Ant 1.5.4, xmltask 1.11, PMD 4.0 (JDK 1.4 version).

I have a process where I use xmltask to parse one or more Spring context
files, looking for bean classes with certain characteristics.  For each
bean class that I find, I call another target that runs PMD on that
class.  I'd really prefer to accumulate a list of files, and then call
PMD on the entire list.

So, for instance, following this is an excerpt from my build script that
goes through these steps.  Can you think of a practical way I could
rearrange this so I first build a list of classes to process, and then
run PMD in one step?

 <target name="spring.processFile">
  <xmltask source="${spring.fileToProcess}">
   <xmlcatalog> 
    <dtd publicId="-//SPRING//DTD BEAN//EN" 
         location="${basedir}/etc/spring.dtd"/> 
   </xmlcatalog> 
   <call path="/beans/bean[@singleton!='false']" target="processClass"
         inheritAll="true">
    <param name="className" path="@class"/>
   </call>
  </xmltask>
 </target>

 <target name="processClass">
  <propertyregex property="filePath" input="${className}" regexp="\."
                 replace="/" global="true"/>
  <antcall target="runpmd">
   <param name="file" value="${filePath}.java"/>
   <param name="srcroot" value="src/java"/>
  </antcall>
 </target>

 <path id="pmd.classpath">
  <pathelement location="${basedir}/build/classes"/>
  <pathelement location="${pmd.jar}"/>
  <pathelement location="${util-concurrent.jar}"/>
  <pathelement location="${retroweaver-rt.jar}"/>
  <pathelement location="${jaxen.jar}"/>
 </path>

 <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask"
          classpathref="pmd.classpath" />

 <property name="more.rulesets" value=""/>

 <target name="runpmd">
  <pmd
rulesetfiles="${basedir}/etc/pmdrules.ruleset.xml,${more.rulesets}">
   <formatter type="text" toConsole="true"/>
   <fileset dir="${srcroot}">
    <include name="${file}"/>
   </fileset>
  </pmd>
 </target>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message