网上看见的,确实很全,该有的基本都覆盖到了。自己拿来稍微改改就可以用了。

注: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>

一个完整的JENKINS下的ANT BUILD.XML文件的更多相关文章

  1. 一个完整的JENKINS下的ANT BUILD.XML文件(Jenkins可以参考)

    一个完整的JENKINS下的ANT BUILD.XML文件 <?xml version="1.0" encoding="UTF-8"?> <p ...

  2. Jenkins进阶系列之——16一个完整的JENKINS下的ANT BUILD.XML文件

    网上看见的,确实很全,该有的基本都覆盖到了.自己拿来稍微改改就可以用了. 注:property中的value是你自己的一些本地变量.需要改成自己的 <?xml version="1.0 ...

  3. ANT build.xml文件详解

    Ant的优点 跨平台性.Ant是用Java语言编写的,所示具有很好的跨平台性. 操作简单.Ant是由一个内置任务和可选任务组成的. Ant运行时需要一个XML文件(构建文件). Ant通过调用targ ...

  4. [置顶] ANT build.xml文件详解

    Ant的优点 跨平台性.Ant是用Java语言编写的,所示具有很好的跨平台性. 操作简单.Ant是由一个内置任务和可选任务组成的. Ant运行时需要一个XML文件(构建文件). Ant通过调用targ ...

  5. test-output目录中找不到testng-fail.xml原因+Reportng+ant build.xml文件

    test-output目录中找不到testng-fail.xml原因: 在没有加入Reportng 报告的相关jar包前,在test-output目录下是有testng-fail.xml,后面加入了R ...

  6. Eclipse 运行ant build.xml

    在命令行cmd运行mvn clean install,ant compiler,提示上述信息,是因为 maven的这个插件要求jdk1.6,但是本地电脑环境变量jdk版本为1.7.将JAVA_HOME ...

  7. Java eclipse下 Ant build.xml实例详解 附完整项目源码

    在有eclipse集成环境下ant其实不是很重要,但有些项目需要用到,另外通过eclipse来学习和理解ant是个很好的途径,所以写他demo总结下要点,希望能够帮到大家. 一.本人测试环境eclip ...

  8. jenkins之从0到1利用Git和Ant插件打war包并自动部署到tomcat(第五话):总结以及build.xml文件

    前面基本上把整个配置过程都完整地串起来了,包括可能遇到的难点,按照那个套路应该可以配置好自动打包发布的功能.简单总结下我的学习过程,以及遇到问题是怎样解决的. 准备一个项目源码 刚开始在github和 ...

  9. Java MyEclipse下Ant build.xml简单实例详解

    一.下载配置ant 1.首先下载ant: http://www.apache.org/ 下载最新的版本2.解压ant 后设置ANT_HOME, PATH中添加ANT_HOME目录下的bin目录(如:A ...

随机推荐

  1. mysql root用户kill connection报ERROR 1095 (HY000): You are not owner of thread N

    今日某系统mysql root用户kill connection时报ERROR 1095 (HY000): You are not owner of thread N 按说通过root用户具有supe ...

  2. .net学习总结

    .NET 学前入门 了解.Net能做什么 了解.NET,C#语言及其特点(分清.NET和C#的关系),对.Net学习有系统全面的认识. C#基础 变量,赋值运算符.数据类型转换等. 选择结构控制(if ...

  3. css3实现switch开关效果

    之前阿里电面的时候问的一个问题,今天抽时间做了个demo. html结构 <div class="container"> <div class="bg_ ...

  4. Flexbox实现垂直水平居中

    Flexbox(伸缩盒)是CSS3中新增的特性,利用这个属性可以解决页面中的居中问题.只需要3行代码就可以实现,不需要设置元素的尺寸,能够自适应页面. 这个方法只能在现代浏览器上有效,IE10+.ch ...

  5. android 回调函数二:应用实例

    前言:如果对android回调的概念不明白的请看:android 回调函数一:基本概念 1.定义接口 package com.app.util; public interface ZYJCallBac ...

  6. Android—Ormlite框架简单的操作数据库

    大家在Android项目中或多或少的都会使用数据库,为了提高我们的开发效率,当然少不了数据库ORM框架了,尤其是某些数据库操作特别频繁的app:本篇博客将详细介绍ORMLite的简易用法. 下面开始介 ...

  7. IOS单例

    单例就是只有一个实例. 两种常见的创建方法: 1. : static A *a = nil; + (A *)shareInstance { if (!a) a = [[self alloc] init ...

  8. Retrofit源码设计模式解析(下)

    本文将接着<Retrofit源码设计模式解析(上)>,继续分享以下设计模式在Retrofit中的应用: 适配器模式 策略模式 观察者模式 单例模式 原型模式 享元模式 一.适配器模式 在上 ...

  9. C语言-01-基本语法

    一.学前需知 开发工具 windows平台:Visual C++6.0等 mac平台:Xcode6.0等 以下文章内容皆是以Xcode6.0为开发工具,clang编译器. Xcode的一些常用快捷键 ...

  10. 通过设置虚拟机(ubantu15.10)的分辨率达到全屏效果

    最近搭建了一个ubantu 15.10虚拟机,怎么折腾都不能全屏显示.虽然我已经点了,  还是无法达到真正的全屏. 查了一下,http://jingyan.baidu.com/article/0964 ...