用户操作
[留言]  [发消息]  [加为好友] 
订阅我的博客
XML聚合    FeedSky
订阅到鲜果
订阅到Google
订阅到抓虾
teamlet的公告
<img src="http://p.blog.csdn.net/images/p_blog_csdn_net/teamlet/351843/o_sca-logo.jpg"><br><b>本站采用创作共用版权协议, 要求署名、非商业用途和相同方式共享. 转载本站内容必须也遵循“署名-非商业用途-相同方式共享”的创作共用协议.</b><br><br> 关注SOA技术的发展,跟进SCA技术的理论和实现,努力实践。愿与同行者一起分享,互相勉励,共同进步。<br> <img src=http://p.blog.csdn.net/images/p_blog_csdn_net/teamlet/286987/o_1177766963-72.gif></img> <div id="referer"><a href="http://www.clicki.cn/">Clicki</a></div> <script src="http://www.clicki.cn/refer/feeler.php?siteid=13867&userid=13462" ></script>
文章分类
资源联接
Apache Tuscany
Cruise Control
Open CSA
OSOA
SOA Tools Project
Theserverside
中国Java开发网
满江红
知识共享@中国大陆
左邻右舍
donews的blog
msn的blog
Tuscany中文社区
我用Subversion
存档

原创  Ant-Model:CheckStyle 收藏


1、设置 user.properties
  1. # 项目名称
  2. project.name=WebService_Restful
  3. # 项目所在的路径
  4. project.dir=D:\\workspaces\\webservice\\Restful
  5. # 源文件所在的路径
  6. project.src.dir=${project.dir}\\src\\main\\java
2、build.xml

  1. <project name="checkstyle" default="checkstyle" basedir=".">
  2.     <!-- 导入属性文件 -->
  3.     <property file="user.properties" />
  4.     <!-- - - - - - - - - - - - - - - - - - 
  5.           target: init                      
  6.          - - - - - - - - - - - - - - - - - -->
  7.     <target name="init">
  8.         <tstamp />
  9.         <!-- 报告的生成位置 -->
  10.         <property name="project.checkstyle.report.dir" value="${project.dir}/report" />
  11.         <!-- 检测结果的文件名 -->
  12.         <property name="project.check.result.name" value="${project.name}-checkstyle-result-${DSTAMP}.xml" />
  13.         <!-- 检测报告的文件名 -->
  14.         <property name="project.check.report.name" value="${project.name}-checkstyle-report-${DSTAMP}.html" />
  15.         <!-- 所使用的配置文件 -->
  16.         <property name="checkstyle.config" value="${basedir}/sunrising_checks.xml" />
  17.         <!-- 报告风格 -->
  18.         <property name="checkstyle.report.style" value="${basedir}/contrib/checkstyle-noframes.xsl" />
  19.         <!-- 检测结果 -->
  20.         <property name="checkstyle.result" value="${project.checkstyle.report.dir}/${project.check.result.name}" />
  21.         <!-- 检测报告 -->
  22.         <property name="checkstyle.report" value="${project.checkstyle.report.dir}/${project.check.report.name}" />
  23.         <!-- 新建报告所在的文件夹 -->
  24.         <mkdir dir="${project.checkstyle.report.dir}" />
  25.     </target>
  26.     <taskdef resource="checkstyletask.properties" classpath="${basedir}/lib/checkstyle-all-5.0-beta01.jar" />
  27.     <!-- - - - - - - - - - - - - - - - - - 
  28.           target: checkstyle                      
  29.          - - - - - - - - - - - - - - - - - -->
  30.     <target name="checkstyle" depends="init" description="Check java code and report ">
  31.         <echo>"${checkstyle.config}"</echo>
  32.         <checkstyle config="${checkstyle.config}" failOnViolation="false" failureProperty="checkstyle.failure">
  33.             <formatter type="xml" tofile="${checkstyle.result}" />
  34.             <fileset dir="${project.src.dir}" includes="**/*.java" />
  35.         </checkstyle>
  36.         <xslt in="${checkstyle.result}" out="${checkstyle.report}" style="${checkstyle.report.style}" />
  37.     </target>
  38.     <!-- - - - - - - - - - - - - - - - - - 
  39.           target: mailTarget                      
  40.          - - - - - - - - - - - - - - - - - -->
  41.     <target name="mailCheckStyleReport">
  42.         <mail mailhost="mail.mydomain.cn" mailport="25" subject="Checkstyle violation(s) in project ${ant.project.name}" user="myname@mydomain.cn" password="mypass" files="myattchment">
  43.             <from address="ci@mydomain.cn" />
  44.             <replyto address="cimanager@mydomain.cn" />
  45.             <to address="myname@mydomain.cn" />
  46.             <message>TEST MAIL FROM CheckStyle</message>
  47.         </mail>
  48.     </target>
  49. </project>

3、注意

A)CheckStyle的jar位于当前basedir目录的lib中;
B)javax.activation.jar和mail.jar放到apache-ant-1.7.0\lib目录下,否则mailTarget不可用。

发表于 @ 2008年11月10日 13:14:00 | 评论( loading... ) | 编辑| 举报| 收藏

旧一篇:Json升级带来的影响 | 新一篇:Restlet 输出日志说明

  • 发表评论
  • 评论内容:
  •  
Copyright © teamlet
Powered by CSDN Blog