日期:2014-05-16 浏览次数:20754 次
? ? 官方论坛文档写得很烂,让人以为安装了插件后就万事大吉,实际上并不是这样,它只是个静态分析结果的分析插件,而分析结果的生成,却是它完成不了的,你仍然需要在你的ant或maven任务中,写一个任务去执行,生成这个分析结果,通常是一个xml文件,例如:
?
?
<!-- =================================================================== --> <!-- CheckStyle build --> <!-- =================================================================== --> <target name="checkstyle" description="Reports the violations of service source against coding style format"> <taskdef resource="checkstyletask.properties" classpathref="dist.lib" /> <checkstyle failOnViolation="false" config="${lib.path}/check/CheckStyle_hangame.xml"> <classpath refid="dist.lib" /> <fileset dir="${project.src.dir}"> <include name="**/*.java" /> </fileset> <formatter type="xml" toFile="${commonbuild.dir}/checkstyle_errors.xml" /> </checkstyle> </target> <!-- =================================================================== --> <!-- Findbugs build --> <!-- =================================================================== --> <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="dist.lib" /> <property name="findbugs.home" value="/home/irteam/app/findbugs-1.3.9" /> <target name="findbugs" depends="build-jar"> <findbugs home="${findbugs.home}" output="xml" outputFile="${commonbuild.dir}/findbugs_errors.xml"> <sourcePath path="${project.src.dir}" /> <class location="${project.dist.dir}/${project.name}.jar" /> </findbugs> </target> <!-- =================================================================== --> <!-- PMD build --> <!-- =================================================================== --> <target name="pmd"> <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="dist.lib" /> <pmd rulesetfiles="${lib.path}/check/pmd_hangame.xml" encoding="iso-8859-1"> <formatter type="xml" toFile="${commonbuild.dir}/pmd.xml" /> <fileset dir="${project.src.dir}"> <include name="**/*.java" /> </fileset> </pmd> </target>
?并在findbugs插件中指定你生成的文件名才可以,这里生成的叫findbugs_errors.xml,那么你在插件指定的名字也要叫findbugs_errors.xml,其他两个插件类似,不再赘述.
?