PMD其實也跟Android預設的行為沒有關系,因此只要按照其官方檔的寫法加入project的build.xml中即可
<!-- PMD -->
<property name="pmd.home" value="path to your PMD" />
<path id="pmd_lib">
<pathelement location="${pmd.home}/lib/asm-3.1.jar"/>
<pathelement location="${pmd.home}/lib/jaxen-1.1.1.jar"/>
<pathelement location="${pmd.home}/lib/junit-4.4.jar"/>
<pathelement location="${pmd.home}/lib/pmd-4.2.5.jar"/>
</path>

 

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

 

 

<target name="pmd">
<pmd shortFilenames="true">
<ruleset>rulesets/favorites.xml</ruleset>
<ruleset>basic</ruleset>
<formatter type="xml" toFile="pmd.xml"/>
<fileset dir="src">
<include name="**/*.java"/>
</fileset>
</pmd>
</target>

 

參考檔:HTTP://pmd.sourceforge.net/ant-task.html

 

注意:target定義需在<setup />後,taskdef與property等需在<setup />前

 

 
 
 
 
arrow
arrow
    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()