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/处下载使用

  code_rules.xml是公司内部的checkstyle规范文档,可以在http://checkstyle.sourceforge.net/处下载sun公司或者google的代码规范

  checkstyle-frames.xsl是生成checkstyle测试报告的样式表,可以在github上,https://github.com/checkstyle/contribution下面xsl文件下找到

欢迎转载,转载请注明出处:http://www.cnblogs.com/hustar0102/p/5885115.html

转载于:https://www.cnblogs.com/hustar0102/p/7218255.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值