Jenkins进阶系列之——16一个完整的JENKINS下的ANT BUILD.XML文件
2014-12-08:已不再担任SCM和CI的职位,Jenkins系列的文章如无必要不会再维护。
网上看见的,确实很全,该有的基本都覆盖到了。自己拿来稍微改改就可以用了。
注:property中的value是你自己的一些本地变量。需要改成自己的
<?xml version="1.0" encoding="UTF-8"?>
<project name="genwar" default="all" basedir="."> <description> - Generate war file - </description> <property environment="env" /> <property name="debuglevel" value="source,lines,vars" />
<property name="target" value="1.6" />
<property name="source" value="1.6" /> <property name="output.dir" location="." />
<property name="output.file" value="new_cos.war" /> <property name="project.build" location="./build" />
<property name="project.src" location="./src" />
<property name="project.web" location="../web" />
<property name="project.lib" location="./lib" />
<property name="project.res" location="./res" />
<property name="project.svc" location="./svc" /> <property name="project.war" location="${project.build}/${output.file}" /> <property name="tmp" location="${project.build}/tmp" />
<property name="tmp.src" location="${tmp}/src" />
<property name="tmp.lib" location="${project.web}/WEB-INF/lib" />
<property name="tmp.bin" location="${tmp}/bin" />
<property name="tmp.web" location="${tmp}/web" />
<property name="tmp.classes" location="${tmp}/classes" /> <property name="checkstyle.dir" location="./ant-task/checkstyle" />
<property name="findbugs.dir" location="./ant-task/findbugs/home" />
<property name="findbugs.report.dir" location="./ant-task/findbugs" />
<property name="junit.reports.dir" value="./ant-task/junit/reports" />
<property name="junit.class.dir" value="./ant-task/junit/bin" />
<property name="junit.test.src" location="./test/java" />
<property name="junit.test.resources" location="./test/resources" /> <path id="javaclass.path">
<pathelement path="${env.classpath}" />
<pathelement path="${env.JBOSS_HOME}/server/all/lib/servlet-api.jar" />
<pathelement path="${env.JBOSS_HOME}/server/all/lib/jsp-api.jar" />
<fileset dir="${tmp.lib}" includes="*.jar" />
<!-- <fileset dir="${project.lib}" includes="*.jar" /> -->
</path> <path id="findbugs.path">
<fileset dir="${findbugs.dir}" includes="**/*.jar" />
</path> <target name="clean">
<delete file="${output.dir}/${output.file}" failonerror="false" />
<delete dir="${project.build}" failonerror="false" />
<mkdir dir="${project.build}" />
</target> <target name="all" depends="clean,buildwar" /> <target name="initdir"> <echo message="Init directories " /> <delete dir="${tmp}" failonerror="false" /> <mkdir dir="${tmp}" /> <mkdir dir="${tmp.src}" />
<copy todir="${tmp.src}">
<fileset dir="${project.src}" excludes="**/.svn/**" />
</copy> <mkdir dir="${tmp.lib}" />
<!--
<copy todir="${tmp.lib}">
<fileset dir="${project.web}/WEB-INF/lib" includes="*.jar" />
</copy>
--> <mkdir dir="${tmp.bin}" /> <mkdir dir="${tmp.web}/WEB-INF/lib" /> <delete dir="${tmp.web}/WEB-INF/classes" failonerror="false" />
<mkdir dir="${tmp.web}/WEB-INF/classes" /> </target> <target name="compilejava" depends="initdir">
<echo message="Compiling java code " /> <javac debug="true" debuglevel="${debuglevel}" destdir="${tmp.bin}" source="${source}" target="${target}" encoding="UTF-8">
<src path="${tmp.src}" />
<classpath refid="javaclass.path" />
</javac> <copy todir="${tmp.web}/WEB-INF/classes" includeemptydirs="false">
<fileset dir="${tmp.src}">
<exclude name="**/*.java" />
</fileset>
</copy>
<copy todir="${tmp.web}/WEB-INF/classes" includeemptydirs="false">
<fileset dir="${tmp.bin}">
<include name="**/*.class" />
</fileset>
</copy>
</target> <target name="compilejava-without-copy" depends="initdir">
<echo message="Compiling java code " /> <javac debug="true" debuglevel="${debuglevel}" destdir="${tmp.bin}" source="${source}" target="${target}" encoding="UTF-8">
<src path="${tmp.src}" />
<classpath refid="javaclass.path" />
</javac> </target> <target name="buildwar" depends="compilejava"> <echo message="Packing war file " /> <copy todir="${tmp.web}">
<fileset dir="${project.web}" excludes="**/.svn/**" />
</copy> <delete file="${project.war}" failonerror="false" />
<war destfile="${project.war}" basedir="${tmp.web}" webxml="${tmp.web}/WEB-INF/web.xml" encoding="utf-8" />
<delete dir="${tmp}" failonerror="false" /> <delete file="${output.dir}/${output.file}" failonerror="false" />
<move todir="${output.dir}" includeemptydirs="false" filtering="true">
<fileset dir="${project.build}">
<include name="**/*.war" />
</fileset>
</move> <delete dir="${project.build}" failonerror="false" /> </target> <taskdef resource="checkstyletask.properties"
classpath="${checkstyle.dir}/checkstyle-5.5-all.jar"/> <target name="checkstyle"
description="Generates a report of code convention violations."> <checkstyle config="${checkstyle.dir}/my_check.xml"
failureProperty="checkstyle.failure" failOnViolation="false">
<formatter type="xml" tofile="${checkstyle.dir}/checkstyle_report.xml" />
<fileset dir="${project.src}" includes="**/*.java" />
</checkstyle> <!-- style in="checkstyle_report.xml" out="checkstyle_report.html"
style="checkstyle.xsl" /--> </target> <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"
classpathref ="findbugs.path"/> <target name="findbugs" depends="compilejava-without-copy"
description="用Findbugs检查代码错误.">
<echo>开始用Findbugs检查代码错误</echo>
<findbugs home="${findbugs.dir}" output="xml"
outputFile="${findbugs.report.dir}/findbugs_report.xml" >
<auxClasspath >
<path refid="junit.test.lib.path" />
</auxClasspath>
<!--auxClasspath path="${basedir}/lib/Regex.jar" /-->
<sourcePath path="${tmp.src}" />
<class location="${tmp.bin}" />
</findbugs>
<echo>Findbugs检查代码错误完成</echo> <delete dir="${project.build}" failonerror="false" />
</target> <target name="junit-init" >
<delete dir="${junit.class.dir}" failonerror="false" />
<mkdir dir="${junit.class.dir}" />
<delete dir="${junit.reports.dir}/result-xml" failonerror="false" />
<mkdir dir="${junit.reports.dir}/result-xml" />
<delete dir="${junit.reports.dir}/html" failonerror="false" />
<mkdir dir="${junit.reports.dir}/html" />
<delete dir="${junit.reports.dir}/html-result" failonerror="false" />
<mkdir dir="${junit.reports.dir}/html-result" />
</target> <target name="junit-compile" depends="junit-init">
<echo message="${project.web}/WEB-INF/lib"/>
<javac srcdir="${project.src}" destdir="${junit.class.dir}" source="${source}" target="${target}" encoding="UTF-8">
<classpath refid="junit.test.lib.path" />
</javac>
<javac srcdir="${junit.test.src}" destdir="${junit.class.dir}" source="${source}" target="${target}" encoding="UTF-8">
<classpath refid="junit.test.lib.path" />
</javac>
<copy todir="${junit.class.dir}">
<fileset dir="${junit.test.resources}">
<include name="**/*.xml" />
</fileset>
</copy>
<copy todir="${junit.class.dir}">
<fileset dir="${project.src}">
<include name="**/*.xml" />
</fileset>
</copy>
</target> <path id="junit.test.lib.path">
<pathelement path="${env.JBOSS_HOME}/server/all/lib/servlet-api.jar" />
<pathelement path="${env.JBOSS_HOME}/server/all/lib/jsp-api.jar" />
<pathelement path="${env.JBOSS_HOME}/server/all/lib/jboss-j2ee.jar" />
<fileset dir="${project.web}/WEB-INF/lib" includes="**/*.jar" />
<fileset dir="${project.lib}" includes="**/*.jar" />
</path> <target name="junit-test" depends="junit-compile">
<junit printsummary="yes">
<classpath>
<!-- 指定lib和class路径,class和jar的声明不能混在一起 -->
<pathelement location="${junit.class.dir}" />
<path refid="junit.test.lib.path" />
</classpath>
<batchtest todir="${junit.reports.dir}/result-xml">
<fileset dir="${junit.test.src}" includes="**/*TestCase.java" />
<formatter type="xml" />
</batchtest>
</junit>
<junitreport todir="${junit.reports.dir}/html-result">
<!-- 指定测试结果的XML,即上一步产生的XML -->
<fileset dir="${junit.reports.dir}/result-xml">
<include name="TEST-*.xml" />
</fileset>
<!-- 根据测试结果XML,生成TESTS-TestSuites.xml,并由此产生HTML文件 -->
<report format="frames" todir="${junit.reports.dir}/html" />
<!--
-->
</junitreport>
</target>
</project>
文章来源:http://www.blogjava.net/paulwong/archive/2012/02/08/369617.html
Jenkins进阶系列之——16一个完整的JENKINS下的ANT BUILD.XML文件的更多相关文章
- 一个完整的JENKINS下的ANT BUILD.XML文件(Jenkins可以参考)
一个完整的JENKINS下的ANT BUILD.XML文件 <?xml version="1.0" encoding="UTF-8"?> <p ...
- 一个完整的JENKINS下的ANT BUILD.XML文件
网上看见的,确实很全,该有的基本都覆盖到了.自己拿来稍微改改就可以用了. 注:property中的value是你自己的一些本地变量.需要改成自己的 <?xml version="1.0 ...
- 【ABAP系列】SAP 一个完整的SAP的Abap例子(idoc,edi文件的相互转换)
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP 一个完整的SAP的Aba ...
- Jenkins进阶系列之——01使用email-ext替换Jenkins的默认邮件通知
1 简述 众所周知,Jenkins默认提供了一个邮件通知,能在构建失败.构建不稳定等状态后发送邮件.但是它本身有很多局限性,比如它的邮件通知无法提供详细的邮件内容.无法定义发送邮件的格式.无法定义灵活 ...
- Jenkins进阶系列之——17Jenkins升级、迁移和备份
升级Jenkins Jenkins的开发迭代非常快,每周发布一个开发版本,长期支持版每半年更新一次(ps:大版本更新).如此频繁的更新,怎么升级呢? war:下载新版的war文件,替换旧版本war文件 ...
- jenkins之从0到1利用Git和Ant插件打war包并自动部署到tomcat(第五话):总结以及build.xml文件
前面基本上把整个配置过程都完整地串起来了,包括可能遇到的难点,按照那个套路应该可以配置好自动打包发布的功能.简单总结下我的学习过程,以及遇到问题是怎样解决的. 准备一个项目源码 刚开始在github和 ...
- Java eclipse下 Ant build.xml实例详解 附完整项目源码
在有eclipse集成环境下ant其实不是很重要,但有些项目需要用到,另外通过eclipse来学习和理解ant是个很好的途径,所以写他demo总结下要点,希望能够帮到大家. 一.本人测试环境eclip ...
- Jenkins进阶系列之——08Jenkins纳入版本控制
2014-07-25:更新shell脚本 2014-06-05:更新shell脚本 2014-01-09:更新shell脚本,修改Jenkins文件删除后不能自动从版本控制删除的bug 是不是有过这种 ...
- Jenkins进阶系列之——13修改Jenkins权限控制
说明:本方法适用于安全矩阵和项目矩阵授权策略的Jenkins. 很多童鞋在使用jenkins的时候忘记配置权限或者权限配置错误,然后各种蛋疼.最近闲着无事,折腾了下.好了,闲话少扯. Jenkins的 ...
随机推荐
- openstack 上床镜像, 创建网络, 创建虚拟机 命令
==================================================================================================== ...
- (android) SharedPreferences 两种方式的存储范围
1 SharedPreferences settings =Activity.getPreferences(Activity.MODE_PRIVATE); 访问数据的范围为 当前的activity 2 ...
- statement和preparedstatement用法区别
1. PreparedStatement接口继承Statement, PreparedStatement 实例包含已编译的 SQL 语句,所以其执行速度要快于 Statement 对象. 2.作为 ...
- 用VB实现点名程序
用vb实现点名程序主要是随机变量的产生和数据的读取和存储以及计时器程序的设计,读取的文件命名为data.txt,书写格式为第一行为总人数下面的每行为一个人名,在应用时最好把data文件和程序文件放在一 ...
- linux—【用户和组的管理操作】(5)
用户:user 组:group 增加:add 修改:modify mod 删除:delete del useradd 增加用户 usermod 修改用户 userdel ...
- (转)c++类的成员函数存储方式(是否属于类的对象)---一道面试题引发的思考
昨天去面试一家公司,面试题中有一个题,自己没弄清楚,先记录如下: class D { public: void printA() { cout<<"printA"< ...
- 分布式服务框架 Zookeeper(转)
分布式服务框架 Zookeeper -- 管理分布式环境中的数据 Zookeeper 分布式服务框架是 Apache Hadoop 的一个子项目,它主要是用来解决分布式应用中经常遇到的一些数据管理问题 ...
- 2014 Super Training #9 E Destroy --树的直径+树形DP
原题: ZOJ 3684 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3684 题意: 给你一棵树,树的根是树的中心(到其 ...
- 在3D Max中查看模型引用的贴图
需求 假如在Max中有一个模型,想查看贴图 操作步骤 1.右上角点击 2.在弹出材质编辑器中 点击吸管 3.把吸管点击在角色模型上,然后点击M 4.点击查看图像 5.就能查看到模型使用的贴图
- BUG描述规范
BUG描述规范 一. 目的与适用范围 1.1 目的 报告软件测试错误的目的是为了保证修复错误的人员可以明确报告的错误,从而有利于分析错误产生的原因,定位错误,然后修正之.因此,报告软件测试错误的基本要 ...