CC checkstyle
来源:互联网 发布:php和mysql的关系 编辑:程序博客网 时间:2024/05/01 13:07
CC下载安装: <!-- See http://jakarta.apache.org/ant for info about ANT --> <project name="checkstyle" default="checkstyle" basedir="."> </project>get http://umn.dl.sourceforge.net/sourceforge/checkstyle/checkstyle-3.4.tar.gz
配置一个检查标准
tar zxvf checkstyle-3.4.tar.gz
cd checkstyle-3.4
此时,checkstyle自身及其所需的jar包都在这个目录,平常我们只用checkstyle-all-3.4.jar一个包就可以了。子目录contrib下有几xsl文件,是用于检查结果的样式文件。
参考资料2,对如果配置checkstyle作了详细了说明,我这儿用的也是他的配置文件。但ant脚本,建议参考我下面的,他的有一个小错误(我已经在他的文章评论里说了一下。)
进行源代码的自动检查
build.xml的内容如下:<!DOCTYPE project>
现在,运行ant checkstyle-nightly,如果一切正常,你就会在收信方的邮箱里找到相应的邮件了。
<!-- ANT make file checkstype -->
<target name="init">
<tstamp/>
<!-- CheckStyle配置,这里你替换成你实际的环境 -->
<property name="project.docs.dir" value="${basedir}/contrib" />
<property name="project.src.dir" value="/path/to/your/source/codes" />
<property name="project.checkstyleReport.dir" value="${basedir}/build" />
<property name="checkstyle.jar" value="${basedir}/checkstyle-all-3.4.jar"/>
<property name="checkstyle.config" value="${project.docs.dir}/mycheck.xml"/>
<property name="checkstyle.report.style" value="${project.docs.dir}/checkstyle-noframes.xsl"/>
<property name="checkstyle.result" value="${project.checkstyleReport.dir}/checkstyle_result.xml"/>
<property name="checkstyle.report" value="${project.checkstyleReport.dir}/checkstyle_report.html"/>
</target>
<!--CheckStyle脚步-->
<taskdef resource="checkstyletask.properties" classpath="${checkstyle.jar}" />
<target name="checkstyle" depends="init" description=" 对java源代码进行检查并产生检查报告. ">
<checkstyle config="${checkstyle.config}" failOnViolation="false" failureProperty="checkstyle.failure">
<formatter type="xml" tofile="${checkstyle.result}"/>
<fileset dir="${project.src.dir}" includes="**/*.java"/>
</checkstyle>
<!-- 生成报告,其格式取决于${checkstyle.report.style} -->
<style in="${checkstyle.result}" out="${checkstyle.report}" style="${checkstyle.report.style}"/>
</target>
<!-- 当有不规范的情况发生时将检查结果发送到 -->
<target name="checkstyle-nightly"
depends="checkstyle"
if="checkstyle.failure"
description="Sends email if checkstyle detected code conventions violations.">
<mail from="发信方的email"
tolist="收信方的email"
mailhost="发信方email的服务器"
subject=" checkstyle result from project reports"
files="${checkstyle.report}"/>
</target>
说明:
- CC checkstyle
- Checkstyle
- CheckStyle
- Checkstyle
- Checkstyle
- Checkstyle
- CheckStyle
- checkstyle
- checkStyle
- cc
- cc
- CC
- cc
- cc
- cc++
- cc
- cc
- cc
- 阿里巴巴2次面试归来
- 一个想踏入游戏行业的人的独白
- mysql问题还真多
- Lifehacker 26款最佳软件名单 (Hive Five精选)
- bad mood
- CC checkstyle
- BTREE二叉树模板类C++
- 狗日的票贩子
- MSComm 控件的Input 属性及InputMode 属性探究
- C#中ref和out的区别
- MASM32编程在屏幕右下角自下向上显示倒计时窗口
- galgame 游戏动画汉化(动画外挂字幕)和字幕合成方法
- Spring源代码分析(8)---ClassPathXmlApplicationContext(工厂换新颜)
- Win32程序中显示JPG、GIF