- 浏览: 20343 次
- 性别:
- 来自: 深圳
最新评论
虽然以前就知道敏捷开发,并且也参加了一些沙龙,在开发过程中也用了TDD做开发,但是一直没有做持续集成,5月10号参加了百度App开发者大会,在会上和别的朋友交流了敏捷开发相关东东,决定还是要做每日构建,于是开始查资料,做持续集成的测试。在网上找到一篇好文章 ,上面有指导文档下载(强烈推荐),经过这两天测试,在指导文档的指引下,终于调通了,我采用Ant+Hudson+Vss+Emma+PMD+FindBugs+Jabber...,下面附上我的Build.xml,主要看target为ci关联的部分。
<?xml version="1.0" encoding="UTF-8"?> <project name="testhudsonvss" default="deploy" basedir="."> <property name="pmd.home" value="E:/Source/Java/component/pmd-4.2.5"/> <property name="javancss.home" value="E:/Source/Java/component/javancss-32.53"/> <property name="findbugs.home" value="E:/Source/Java/component/findbugs-1.3.9"/> <property name="emma.home" value="E:/Source/Java/component/emma-2.0.5312"/> <property name="emma.enabled" value="true"/> <property name="junit.home" value="E:/Source/Java/component/junit4.6"/> <property name="checkstyle.home" value="E:/Source/Java/component/checkstyle-5.3"/> <property name="dist.dir" value="dist"/> <property name="build.dir" value="build"/> <property name="src.build.dir" value="${build.dir}/classes"/> <property name="emma.src.build.dir" value="${build.dir}/instr"/> <property name="test.build.dir" value="${build.dir}/test"/> <property name="lib.dir" value="lib"/> <property name="src.dir" value="src"/> <property name="test.dir" value="test"/> <property name="test.report.dir" value="${test.dir}/report"/> <property name="app.name" value="TestHudsonVss"/> <path id="app.classpath"> <fileset dir="${lib.dir}"> <include name="**/*.jar"/> </fileset> </path> <path id="junit.classpath"> <fileset dir="${junit.home}"> <include name="junit-4.6.jar"/> </fileset> </path> <path id="test.classpath"> <pathelement path="${src.build.dir}"/> <path refid="app.classpath"/> <path refid="junit.classpath"/> </path> <path id="findbugs.classpath"> <fileset dir="${findbugs.home}/lib"> <include name="**/*.jar"/> </fileset> </path> <path id="javancss.classpath"> <fileset dir="${javancss.home}/lib"/> </path> <path id="checkstyle.classpath"> <fileset dir="${checkstyle.home}"> <include name="**/checkstyle-5.3-all.jar"/> </fileset> </path> <path id="pmd.classpath"> <fileset dir="${pmd.home}/lib/"> <include name="*.jar"/> </fileset> </path> <path id="emma.classpath"> <fileset dir="${emma.home}/lib"> <include name="**/*.jar"/> </fileset> </path> <path id="emma.test.classpath"> <pathelement path="${emma.src.build.dir}"/> <path refid="app.classpath"/> <path refid="junit.classpath"/> </path> <target name="clean" description="==清理构建环境=="> <echo message="==Clean Project=="/> <delete dir="${build.dir}" failonerror="off"/> <delete dir="${dist.dir}" failonerror="off"/> <delete dir="${test.report.dir}" failonerror="off"/> <delete dir="checkstyle" failonerror="off"/> </target> <target name="prepare" description="==准备构建==" depends="clean"> <echo message="==Prepare Project=="/> <mkdir dir="${src.build.dir}"/> <mkdir dir="${test.build.dir}"/> <mkdir dir="${test.dir}"/> <mkdir dir="${dist.dir}"/> <mkdir dir="${test.report.dir}"/> </target> <target name="pmd" description="pmd-check" depends="prepare"> <echo message="==pmd=="/> <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="pmd.classpath"/> <pmd shortFilenames="true"> <ruleset>rulesets/favorites.xml</ruleset> <ruleset>basic</ruleset> <formatter type="xml" toFile="${dist.dir}/pmd.xml"/> <fileset dir="${src.dir}" includes="**/*.java"/> <fileset dir="${test.dir}" includes="**/*.java"/> </pmd> </target> <target name="javancss" description="javaNCSS" depends="prepare"> <echo message="==javancss=="/> <mkdir dir="${dist.dir}/javancss"/> <taskdef name="javancss" classname="javancss.JavancssAntTask" classpathref="javancss.classpath"/> <javancss srcdir="${src.dir}" includes="**/*.java" generateReport="true" outputfile="${dist.dir}/javancss-report.xml" format="xml"/> <!--<style in="${dist.dir}/javancss-report.xml" out="${dist.dir}/javancss/javancss_report.html" style="${javancss.home}/xslt/javancss2html.xsl" mce_style="${javancss.home}/xslt/javancss2html.xsl"/>--> <xslt style="${javancss.home}/xslt/javancss2html.xsl" mce_style="${javancss.home}/xslt/javancss2html.xsl" in="${dist.dir}/javancss-report.xml" out="${dist.dir}/javancss/javancss_report.html"/> </target> <target name="checkstyle" depends="prepare"> <echo message="==CheckStyle=="/> <mkdir dir="${dist.dir}/checkstyle"/> <taskdef resource="checkstyletask.properties" classpathref="checkstyle.classpath"/> <checkstyle config="${checkstyle.home}/springside3_checks.xml" failureProperty="checkstyle.failure" failOnViolation="false"> <formatter type="xml" tofile="${dist.dir}/checkstyle_report.xml"/> <fileset dir="${src.dir}" includes="**/*.java"/> <fileset dir="${test.dir}" includes="**/*.java"/> </checkstyle> <style in="${dist.dir}/checkstyle_report.xml" out="${dist.dir}/checkstyle/checkstyle_report.html" style="${checkstyle.home}/contrib/checkstyle-simple.xsl" mce_style="${checkstyle.home}/contrib/checkstyle-simple.xsl"/> </target> <target name="compile" description="==编译源代码==" depends="prepare"> <echo message="==Compile Source Code=="/> <javac debug="true" destdir="${src.build.dir}" deprecation="true"> <src path="${src.dir}"/> <classpath refid="app.classpath"/> </javac> <echo message="==Copy Config File=="/> <copy todir="${src.build.dir}"> <fileset dir="${src.dir}" includes="**/*.xml"/> <fileset dir="${src.dir}" includes="**/*.properties"/> <fileset dir="META-INF/" includes="**/*"/> </copy> </target> <target name="findbugs" description="==动态分析源代码中可能存在的bug==" depends="compile"> <echo message="==FindBugs=="/> <mkdir dir="${dist.dir}/findbugs"/> <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="findbugs.classpath"> </taskdef> <findbugs projectname="FindBugs-TestHudsonVss" home="${findbugs.home}" output="html" outputfile="${dist.dir}/findbugs/FindBugs.html" jvmargs="-Xms128m -Xmx256m" stylesheet="fancy-hist.xsl"> <class location="${src.build.dir}"/> </findbugs> </target> <target name="findbugs-xml" description="==动态分析源代码中可能存在的bug==" depends="compiletest"> <echo message="==FindBugs=="/> <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="findbugs.classpath"> </taskdef> <findbugs projectname="FindBugs-TestHudsonVss" home="${findbugs.home}" output="xml" outputfile="${dist.dir}/findbugs.xml" jvmargs="-Xms128m -Xmx256m"> <class location="${src.build.dir}"/> <class location="${test.build.dir}"/> </findbugs> </target> <target name="compiletest" description="==编译测试代码==" depends="compile"> <echo message="==Compile Test Code=="/> <javac debug="true" destdir="${test.build.dir}" deprecation="true"> <src path="${test.dir}"/> <classpath refid="test.classpath"/> </javac> <echo message="==Copy Test Config File=="/> <copy todir="${test.build.dir}"> <fileset dir="${test.dir}"> <include name="**/*.xml"/> <include name="**/*.properties"/> </fileset> </copy> </target> <target name="test" description="==运行测试代码==" depends="compiletest"> <echo message="==Run Test Code=="/> <junit printsummary="withOutAndErr" errorproperty="test.failed" failureproperty="test.failed"> <classpath refid="test.classpath"/> <classpath location="${test.build.dir}"/> <formatter type="xml"/> <batchtest todir="${test.report.dir}"> <fileset dir="${test.build.dir}" excludes="**/*BaseTest.class"> <include name="**/*Test.class"/> <exclude name="**/AllTest.class"/> </fileset> </batchtest> </junit> <fail message="Tests failed. Check log and/or reports" if="test.failed"/> </target> <target name="genjunitreport" description="==产生JUnit报告=="> <echo message="==Generate JUnit Report=="/> <junitreport todir="${test.report.dir}"> <fileset dir="${test.report.dir}"> <include name="TEST-*.xml"/> </fileset> <report format="frames" todir="${test.report.dir}/html/"/> </junitreport> </target> <target name="testandreport" depends="test,genjunitreport" description="==运行测试代码并产生报告=="> </target> <target name="instrument" description="==字节码增强==" depends="compile"> <echo message="==Emma Code Instrument=="/> <taskdef resource="emma_ant.properties" classpathref="emma.classpath"/> <mkdir dir="${emma.src.build.dir}"/> <mkdir dir="${dist.dir}/emma"/> <emma enabled="${emma.enabled}"> <!--<instr inst="${src.build.dir}" destdir="${emma.src.build.dir}" metadatafile="${dist.dir}/emma/metadata.emma"--> <!--merge="true"/>--> <instr instrpath="${src.build.dir}" destdir="${emma.src.build.dir}" metadatafile="${dist.dir}/emma/metadata.emma" merge="true"> </instr> </emma> <copy todir="${build.dir}/instr" overwrite="false"> <fileset dir="${src.dir}" includes="**/*.xml"/> <fileset dir="${src.dir}" includes="**/*.properties"/> <fileset dir="${src.build.dir}"> <include name="**/*.class"/> </fileset> </copy> </target> <!--<target name="emmatestcompile" description="==编译所有的测试代码==" depends="instrument">--> <!--<echo message="==Compile Emma Test Code==">--> <!--</echo>--> <!--<javac debug="true" destdir="${build.dir}/test" deprecation="true" source="1.5" includeantruntime="on">--> <!--<src path="${test.dir}"/>--> <!--<classpath refid="emma.test.classpath"/>--> <!--</javac>--> <!--<copy todir="${build.dir}/test">--> <!--<fileset dir="${test.dir}">--> <!--<include name="**/*.xml"/>--> <!--<include name="**/*.properties"/>--> <!--</fileset>--> <!--</copy>--> <!--</target>--> <target name="emmatest" depends="compiletest,instrument" description="==编译Emma测试代码=="> <echo message="==Run EMMA Test Code=="/> <junit printsummary="withOutAndErr" errorproperty="test.failed" failureproperty="test.failed" fork="true" forkmode="once"> <jvmarg value="-Demma.coverage.out.file=${dist.dir}/emma/metadata.emma"/> <jvmarg value="-Demma.coverage.out.merge=true"/> <classpath refid="emma.test.classpath"/> <classpath location="${build.dir}/test"/> <classpath refid="emma.classpath"/> <formatter type="xml"/> <batchtest todir="${test.report.dir}"> <fileset dir="${test.build.dir}" excludes="**/*BaseTest.class"> <include name="**/*Test.class"/> <exclude name="**/AllTest.class"/> </fileset> </batchtest> </junit> <fail message="Tests Emma failed. Check log and/or reports" if="test.failed"/> </target> <!-- 生成测试覆盖率报告--> <target name="emmareport" depends="emmatest,genjunitreport"> <echo message="==Generate JUnit Report and Emma Report=="/> <taskdef resource="emma_ant.properties" classpathref="emma.classpath"/> <emma enabled="${emma.enabled}"> <report sourcepath="${src.dir}" sort="+block,+name,+method,+class" metrics="method:70,block:80,line:80,class:100"> <fileset dir="${dist.dir}/emma"> <include name="*.emma"/> </fileset> <xml outfile="${dist.dir}/coverage.xml" depth="package"/> <html outfile="${dist.dir}/emma/core-coverage.html" depth="method" columns="name,class,method,block,line" encoding="UTF-8"/> </report> </emma> </target> <target name="package" description="==生成java Archive发布包==" depends="compile"> <echo message="====Crate Jar===="/> <jar destfile="${dist.dir}/${app.name}.jar" compress="true" update="true"> <fileset dir="${src.build.dir}"> </fileset> </jar> </target> <target name="ci" description="==Continuous Integration==" depends="checkstyle,javancss,pmd,findbugs-xml,emmareport"> </target> <target name="deploy" depends="package,testandreport"> </target> </project>
相关推荐
基于Hudson的持续集成,较笔者之前的一版本增加了对Maven内容的说明,部分内容依赖具体的项目,如未描述清楚,请见谅。
使用 Hudson 持续集成 ppt
使用Hudson持续集成使用Hudson持续集成
持续集成已成为当前许多软件开发团队在整个软件开发生命周期内侧重于保证代码质量的常见做法。本文介绍使用Hudson进行持续集成
Hudson持续集成实战 自动化部署教程
hudson持续集成包hudson持续集成包
Hudson持续集成引擎
通过持续集成控制代码质量 Maven+Hudson+Sonar 持续集成的基本原则很简单:尽早集成,经常集成。 持续自动构建 :使用CI,您只要按一下按钮,它会依照预先制定的时间表,或者响应某一特定事件,就开始进行一次构建...
里面收集了很多关于使用Hudson进行持续集成的资料,方方面面都有些吧~
如何在电脑上配置Hudson并通过Hudson进行持续集成的测试!
hudson持续集成包hudson持续集成包
hudson持续集成包hudson持续集成包
Hudson 是一个可扩展的持续集成引擎。 主要用于: 1.持续、自动地构建/测试软件项目,如CruiseControl与DamageControl。 2.监控一些定时执行的任务。 Hudson拥有的特性包括: •易于安装-只要把hudson.war部署到...
目前较为流行的CI持续测试工具。基于web,配置简单。较之TeamCity等有着较为明显的优势。 本文非常详细的描述了Hudson的配置和应用。对持续集成CI感兴趣的童鞋可以看看。
Hudson持续集成实战 在对一个实际项目进行持续集成之前,预先定义一个合理的目录结构可以大大减轻以后工作中维护工作。对于持续集成来说,这一步是非常有必要的。
持续集成篇--Hudson持续集成服务器的安装配置和使用
本文是关于hudson的一个快速使用手册,本文列出了实际工作中会用到的一些基本功能的使用说明。本文内容hudson的版本为1.386。
Hudson持续集成服务器的安装配置和使用
hudson.war是基于Java研发的一款持续集成工具的安装包,hudson是一个可以扩展的持续集成引擎,主要是用它来监控一些定时执行的任务、持续、自动地构建/测试软件项目,有需要的欢迎下载使用。 hudson下载,放在tomcat...