1. 代码质量检查工具FindBugs和Simian(
百度网盘分享地址)。
3. 执行文件。staticCheck.xml
<?xml version="1.0" encoding="UTF-8" ?>
<project name= "staticCheck" default="check" basedir="../">
<property name="src" value="${basedir}/src" />
<property name="classes" value="${basedir}/WebContent/WEB-INF/classes" />
<property name="staticCheck.home" value="${basedir}/staticCheck" />
<property name="findbugs.home" value="${staticCheck.home}/findbugs-3.0.0" />
<property name="simian.home" value="${staticCheck.home}/simian-2.3.35" />
<property name="report" value="${staticCheck.home}/report" />
<target name="check" depends="findbugs, simian" />
<target name="compile" >
<delete dir="${classes}" />
<mkdir dir="${classes}" />
<javac srcdir="${src}" destdir="${classes}" />
</target>
<path id="findbugs.lib" >
<fileset dir="${findbugs.home}/lib" includes="**/*.jar" />
</path>
<!-- 声明Findbugs任务 -->
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="findbugs.lib" />
<target name="findbugs" depends="compile">
<findbugs home="${findbugs.home}" effort="max" reportlevel="low" warningsproperty="true" output="html" outputFile="${report}/findbugs-report.html" jvmargs="-Xmx1024m" >
<!-- 源代码的路径 -->
<sourcePath path="${src}" />
<!-- findbugs查找的类的路径 可以是jar、zip或者是class -->
<class location="${classes}" />
</findbugs>
</target>
<taskdef resource="simiantask.properties" classpath="${simian.home}/simian-2.3.35.jar" />
<target name="simian" >
<!-- 检查java重复6行的代码 -->
<simian threshold="6" language="java">
<fileset dir="${src}" includes="**/*.java" />
<formatter type="plain" toFile="${report}/simian-log.txt" />
</simian>
</target>
</project>