checkstyle+ant生成checkstyle報告

<?xml version="1.0" encoding="UTF-8" ?>
<project name="tibim" default="xml2html"
	xmlns:cs="antlib:com.puppycrawl.tools.checkstyle.ant" basedir=".">
	<description>
		checkstyle tibim project!
	</description>
	<property name="extrlib"
		location="D:\jenkins\svn\web\TiBIM\webapps\web\WEB-INF\lib" />
	<property name="checkstyleFile" value="./checkstyle" />
	<property name="project.src" location="./src" />
	<target name="clean" description="clean up">
		<delete dir="${checkstyleFile}" />
	</target>
	<path id="compile.classpath">
		<fileset dir="${extrlib}">
			<include name="**/*.jar" />
		</fileset>
	</path>
	<target name="init" depends="clean">
		<!-- Create the classes directory structure used by compile -->
		<mkdir dir="${checkstyleFile}" />
	</target>
	<target name="checkstyle" depends="init"
		description="Generates a report of code convention violations.">
		<taskdef
			resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"
			classpath="${extrlib}/checkstyle-8.0-all.jar" />
		<checkstyle config="${extrlib}/code_rules.xml"
			failureProperty="checkstyle.failure" failOnViolation="false">
			<formatter type="xml" tofile="${checkstyleFile}/checkstyle_report.xml" />
			<fileset dir="${project.src}" includes="**/*.java" />
		</checkstyle>
	</target>
	<target name="xml2html" depends="checkstyle">
		<xslt in="${checkstyleFile}/checkstyle_report.xml" out="${checkstyleFile}/checkstyle.html"
			style="${extrlib}/checkstyle-frames.xsl">
			<param name="output.dir" expression="${checkstyleFile}" />
		</xslt>
	</target>
</project>

  其中checkstyle-8.0-all.jar是checkstyle依賴的jar包,能夠在https://sourceforge.net/projects/checkstyle/files/checkstyle/處下載使用html

  code_rules.xml是公司內部的checkstyle規範文檔,能夠在http://checkstyle.sourceforge.net/處下載sun公司或者google的代碼規範java

  checkstyle-frames.xsl是生成checkstyle測試報告的樣式表,能夠在github上,https://github.com/checkstyle/contribution下面xsl文件下找到git

歡迎轉載,轉載請註明出處:http://www.cnblogs.com/hustar0102/p/5885115.htmlgithub

相關文章
相關標籤/搜索