Sample Ant Build File - WAR--reference
I am using the Spring SimpleFormController example to illustrate the build process. The figure below shows the structure of the web application.

All the classes inside the src directory should be compiled and placed in a separate build/classesdirectory. The created war file will be placed inside the dist directory.
So first we create the build/classes and the dist directory. The init target does this job.
1.<target name="init">2.<mkdir dir="build/classes"/>3.<mkdir dir="dist" />4.</target>The next step is to compile all the classes in the src directory and place them in the build/classesdirectory. To do this first you need to add all the lib files inside the "WebContent/WEB-INF/lib" directory to the classpath.
1.<path id="compile.classpath">2.<fileset dir="WebContent/WEB-INF/lib">3.<include name="*.jar"/>4.</fileset>5.</path>The target compile uses the javac task to compile the java classes and it depends on the target init, because only when you have the directory ready you can place the classes inside them.
1.<target name="compile" depends="init" >2.<javac destdir="build/classes" debug="true" srcdir="src">3.<classpath refid="compile.classpath"/>4.</javac>5.</target>The path we created earlier will be refered here using the <classpath> element.
Now we can create the war file using the war task. To create the war file you need to specify the web directory, lib directory and the classes directory. The destfile attribute specifies the war file location and the webxml attribute specifies the web.xml file location.
1.<target name="war" depends="compile">2.<war destfile="dist/AntExample.war" webxml="WebContent/WEB-INF/web.xml">3.<fileset dir="WebContent"/>4.<lib dir="WebContent/WEB-INF/lib"/>5.<classes dir="build/classes"/>6.</war>7.</target>You can use the clean target to clean the project. The clean target deletes the build and the dist directory.
1.<target name="clean">2.<delete dir="dist" />3.<delete dir="build" />4.</target>The complete build.xml file is shown below.
<?xml version="1.0" ?>
<project name="AntExample1" default="war"> <path id="compile.classpath">
<fileset dir="WebContent/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
</path> <target name="init">
<mkdir dir="build/classes"/>
<mkdir dir="dist" />
</target> <target name="compile" depends="init" >
<javac destdir="build/classes" debug="true" srcdir="src">
<classpath refid="compile.classpath"/>
</javac>
</target> <target name="war" depends="compile">
<war destfile="dist/AntExample.war" webxml="WebContent/WEB-INF/web.xml">
<fileset dir="WebContent"/>
<lib dir="WebContent/WEB-INF/lib"/>
<classes dir="build/classes"/>
</war>
</target> <target name="clean">
<delete dir="dist" />
<delete dir="build" />
</target> </project>
reference from:http://www.dzone.com/tutorials/java/ant/ant-sample-build-file-war-1.html
Sample Ant Build File - WAR--reference的更多相关文章
- Gradle Goodness: Rename Ant Task Names When Importing Ant Build File
Migrating from Ant to Gradle is very easy with the importBuild method from AntBuilder. We only have ...
- 【Ant】How to print all the system properties in Ant build file
在Ant里可以使用echoproperties task来达到目的 <target name="run"> <echoproperties /> </ ...
- jenkins之从0到1利用Git和Ant插件打war包并自动部署到tomcat(第五话):总结以及build.xml文件
前面基本上把整个配置过程都完整地串起来了,包括可能遇到的难点,按照那个套路应该可以配置好自动打包发布的功能.简单总结下我的学习过程,以及遇到问题是怎样解决的. 准备一个项目源码 刚开始在github和 ...
- 自动构建War包的Ant build.xml模板
<?xml version="1.0" encoding="UTF-8" ?> <project name="[*****]你的项目 ...
- 一个完整的JENKINS下的ANT BUILD.XML文件(Jenkins可以参考)
一个完整的JENKINS下的ANT BUILD.XML文件 <?xml version="1.0" encoding="UTF-8"?> <p ...
- Ant build.xml
Ant的概念可能有些读者并不连接什么是Ant以及入可使用它,但只要使用通过Linux系统得读者,应该知道make这个命令.当编译Linux内核及一些软件的源程序时,经常要用这个命令.Make命令其实就 ...
- ant build打包
使用ant build进行增量打包 <?xml version="1.0" encoding="gb2312"?> <project name ...
- Java MyEclipse下Ant build.xml简单实例详解
一.下载配置ant 1.首先下载ant: http://www.apache.org/ 下载最新的版本2.解压ant 后设置ANT_HOME, PATH中添加ANT_HOME目录下的bin目录(如:A ...
- Java Ant build.xml详解
1,什么是antant是构建工具2,什么是构建概念到处可查到,形象来说,你要把代码从某个地方拿来,编译,再拷贝到某个地方去等等操作,当然不仅与此,但是主要用来干这个3,ant的好处跨平台 --因为 ...
随机推荐
- 总结一下SQL语句中引号(')、quotedstr()、('')、format()在SQL语句中的用法
总结一下SQL语句中引号(').quotedstr().('').format()在SQL语句中的用法 日期:2005年6月1日 作者:seasky212 总结一下SQL语句中引号(').quoted ...
- ElasticSearch大数据分布式弹性搜索引擎使用—从0到1
阅读目录: 背景 安装 查找.下载rpm包 .执行rpm包安装 配置elasticsearch专属账户和组 设置elasticsearch文件所有者 切换到elasticsearch专属账户测试能否成 ...
- Yii CDbCriteria
Yii的Active Recorder包装了很多. 特别是把SQL中 把where,order,limit,IN/not IN,like等常用短句都包含进CDbCriteria这个类中去,这样整个代码 ...
- mplayer windows configure修改
相信大家在编译mplayer的时候,都会遇到一个问题,就是那个折腾人的mplayer会检测当面目录下有没有ffmpeg的文件夹. 没有的话,mplayer会启动git进行漫长的下载ffmpeg源码.其 ...
- Linux -- Ubuntu搭建java开发环境
Steps 1 Check to see if your Ubuntu Linux operating system architecture is 32-bit or 64-bit, open up ...
- BZOJ3781: 小B的询问
3781: 小B的询问 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 146 Solved: 98[Submit][Status] Descript ...
- 从头开始编写一个Orchard网上商店模块(3) - 创建Orchard.Webshop模块项目
原文地址:http://skywalkersoftwaredevelopment.net/blog/writing-an-orchard-webshop-module-from-scratch-par ...
- CSS3/SVG clip-path路径剪裁遮罩属性简介
一.SVG属性和CSS3属性千丝万缕的关系 CSS3新增属性除了我们现在用的比较多的border-radius, box-shadow, gradient, ...之类,还有很重要的一个分支:SVG属 ...
- HDU5653 Bomber Man wants to bomb an Array 简单DP
题意:bc 77 div1 1003(中文题面) 分析:先不考虑将结果乘以 1e6. 设 dp[i] 为从前 i 个格子的状态可以获得的最大破坏指数. 那么我们可以枚举每个炸弹,该炸弹向左延伸的距离和 ...
- Oracle行转列的函数
--行转列的函数-- CREATE OR REPLACE FUNCTION Calvin( col IN VARCHAR2,dw IN VARCHAR2) RETURN VARCHAR2 IS ret ...