zoukankan      html  css  js  c++  java
  • 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:jenkinssvnwebTiBIMwebappswebWEB-INFlib" />
    	<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

  • 相关阅读:
    UVA-10917 Walk Through the Forest (dijkstra+DP)
    UVA-11374 Airport Express (dijkstra+枚举)
    UVA-11294 Wedding (2-SAT)
    UVALive-3713 Astronauts (2-SAT)
    UVALive-3211 Now or later (2-SAT+二分)
    线程变量
    linux通用双向链表
    排序算法代码
    双向链表
    long与int的区别?(zz)
  • 原文地址:https://www.cnblogs.com/hustar0102/p/7218255.html
Copyright © 2011-2022 走看看