<!-- 产生javadoc -->
<target name="javadoc" depends="init">
<mkdir dir="${doc.api}"/>
<javadoc packagenames="${javadoc.package}" sourcepath="${src.code}"
private="yes" defaultexcludes="yes" destdir="${doc.dir}/api">
<classpath refid="classpath"/>
</javadoc>
</target>
<!-- 编译Junit文件 -->
<target name="compilejunit" depends="compilesrc">
<mkdir dir="${dist.junit}"/>
<javac destdir="${dist.junit}" deprecation="on">
<src path="${src.junit}"/>
<classpath refid="classpath"/>
<classpath refid="proj.libs"/>
</javac>
</target>
<!-- 运行checkstyle检查代码规范 -->
<target name="checkstyle" depends="init">
<checkstyle config="${checkstyle.config}">
<fileset dir="${src.code}" includes="**/*.java"/>
<formatter type="plain"/>
<formatter type="xml" toFile="${dist.root}/checkstyle_errors.xml"/>
</checkstyle>
</target>
<!-- 运行junit -->
<target name="junit" depends="compilejunit">
<junit printsummary="yes" haltonfailure="yes">
<classpath>
<path refid="classpath"/>
<pathelement location="${dist.junit}"/>
</classpath>
<formatter type="plain"/>
<!-- test name="com.TestClassTest" haltonfailure="no" outfile="result"/ -->
<batchtest todir="${dist.junit}">
<fileset dir="${dist.junit}" includes="**/Test*.class" />
</batchtest>
</junit>
</target>
<!-- 清除产生的类、junit相关类、文档 -->
<target name="clean">
<delete dir="${dist.classes}"/>
<delete dir="${dist.junit}"/>
<delete dir="${doc.api}"/>
</target>
<!-- 清除所有输出结果 -->
<target name="cleanall" depends="clean">
<delete dir="${doc.dir}"/>
<delete dir="${dist.root}"/>
</target>
</project>
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/