Checkstyle如名所示,是检查java程序源代码编码风格的,是java程序员不可或缺的工具,用以检查自己的编码习惯是否符合公司的要求或sun的约定。当然如果你用了ide,那里可能有相应的功能或插件来帮助程序员来完成这项工作。
也如checkstyle其名所示,它只检查,不进行beautifier操作。所以,它应比较适合用于项目管理,用于dailybuild.如果你想借助工具来beautifier你的java源代码,可以参考我写的jalopy安装使用.
下载安装
wget 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文件,是用于检查结果的样式文件。
<!DOCTYPE project>
<!-- ANT make file checkstype --><!-- See http://jakarta.apache.org/ant for info about ANT -->
<project name="checkstyle" default="checkstyle" basedir=".">
<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></project>
You may find it interesting to check some helpful info about... Thanks!!!
Posted by: at December 1, 2004 12:21 PMWhy we need to put some jar like preceding javamail.jar to ANT_HOME/lib?
I found if we do not put these third party library to ANT_HOME/lib, then the execution will not successful even we have put them into the classpath defined in Ant build file.
Why?
Posted by: Leon at November 24, 2004 12:51 AMThe best bitches on the web
Posted by: weak sister bitch at November 13, 2004 03:56 AMdate rape stories http://www.rapestoriespics.com/
Posted by: xxx rape at November 4, 2004 10:40 AMYour ultimate video on demand solutions
Posted by: at September 14, 2004 10:07 PM请教那一位能人开发过z39.50 方面的协议, 请赐教, 或有源代码请给我一份, zhxd78@163.com, 不胜感激!!!!!
Posted by: zhxd78 at August 3, 2004 09:20 AM很不错的一个工具,可以作为eclipse的一个插件使用。
Posted by: howlet at July 18, 2004 07:22 PM