方寸心间
一路走,十年不回头
博客园
::
首页
::
新随笔
::
联系
::
订阅
::
管理
::
245 随笔 :: 7 文章 :: 15 评论 :: 2 引用
我常用的ant配置文件
build.xml如下:
<?
xml version="1.0" encoding="UTF-8"
?>
<
project
name
="yybar"
basedir
="."
default
="build"
>
<!--
Load properties file
<property file="build.properties" />
-->
<!--
App name-dependent settings.
-->
<
property
name
="appname"
value
="${ant.project.name}"
/>
<
property
name
="deploy.resin"
value
="D:/resin3.0.19/webapps"
/>
<
property
name
="deploy.tomcat"
value
="D:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps"
/>
<
property
name
="src.dir"
value
="${basedir}/src"
/>
<
property
name
="data.dir"
value
="${basedir}/data"
/>
<
property
name
="lib.dir"
value
="${basedir}/lib"
/>
<
property
name
="web.dir"
value
="${src.dir}/web"
/>
<
property
name
="build.dir"
value
="${basedir}/build"
/>
<
property
name
="dist.dir"
value
="${basedir}/dist"
/>
<
property
name
="war.dir"
value
="${build.dir}/${appname}"
/>
<
property
name
="webinf.dir"
value
="${war.dir}/WEB-INF"
/>
<
property
name
="class.dir"
value
="${war.dir}/WEB-INF/classes"
/>
<
property
name
="conf.dir"
value
="${src.dir}/conf"
/>
<
property
name
="conf.classes"
value
="${src.dir}/conf/classes"
/>
<
property
name
="conf.webinf"
value
="${src.dir}/conf/WEB-INF"
/>
<
property
name
="warlib.dir"
value
="${war.dir}/WEB-INF/lib"
/>
<
property
name
="war.file"
value
="${dist.dir}/${appname}.war"
/>
<
property
name
="views.dir"
value
="${src.dir}/java/com/easou/${appname}/views"
/>
<
property
name
="controller.dir"
value
="${src.dir}/java/com/easou/${appname}/controller"
/>
<
property
name
="model.dir"
value
="${src.dir}/java/com/easou/${appname}/model"
/>
<
property
name
="util.dir"
value
="${src.dir}/java/com/easou/${appname}/util"
/>
<
property
name
="exception.dir"
value
="${src.dir}/java/com/easou/${appname}/exception"
/>
<
property
name
="test"
value
="${basedir}/test"
/>
<
property
name
="test.src"
value
="${test}/java"
/>
<
property
name
="test.classesdir"
value
="${build.dir}/test/classes"
/>
<
property
name
="test.libpath"
value
="${test}/lib"
/>
<
property
name
="test.confdir"
value
="${test}/etc"
/>
<
property
name
="test.reportdir"
value
="${test}/report"
/>
<
tstamp
>
<
format
property
="build.date"
pattern
="yyyy-MM-dd HH:mm"
/>
</
tstamp
>
<
path
id
="master-classpath"
description
="Master CLASSPATH for this script"
>
<
fileset
dir
="${lib.dir}"
>
<
include
name
="*.jar"
/>
</
fileset
>
<
pathelement
path
="${class.dir}"
/>
</
path
>
<
path
id
="test.lib"
>
<
fileset
dir
="${test.libpath}"
>
<
include
name
="**/*.jar"
/>
</
fileset
>
</
path
>
<
path
id
="lib.total"
>
<
path
refid
="master-classpath"
/>
<
path
refid
="test.lib"
/>
</
path
>
<
target
name
="init"
description
="Setup for build script"
>
<
mkdir
dir
="${class.dir}"
/>
<
mkdir
dir
="${warlib.dir}"
/>
<
mkdir
dir
="${conf.dir}"
/>
<
mkdir
dir
="${conf.classes}"
/>
<
mkdir
dir
="${conf.webinf}"
/>
<
mkdir
dir
="${web.dir}"
/>
<
mkdir
dir
="${lib.dir}"
/>
<
mkdir
dir
="${data.dir}"
/>
<
mkdir
dir
="${views.dir}"
/>
<
mkdir
dir
="${model.dir}"
/>
<
mkdir
dir
="${controller.dir}"
/>
<
mkdir
dir
="${util.dir}"
/>
<
mkdir
dir
="${exception.dir}"
/>
<
mkdir
dir
="${dist.dir}"
/>
</
target
>
<!--
=======================================================
-->
<!--
Convert native properties files to ascii format.
-->
<!--
=======================================================
-->
<
target
name
="unicode"
>
<
delete
>
<
fileset
dir
="${conf.classes}"
includes
="resources*.properties"
/>
</
delete
>
<
native2ascii
encoding
="gb2312"
src
="${conf.classes}"
dest
="${conf.classes}"
includes
="resources*.src"
ext
=".properties"
/>
</
target
>
<
target
name
="updateweb"
depends
="init"
description
="Copies web related files to WAR directory"
>
<
copy
todir
="${war.dir}"
>
<
fileset
dir
="${web.dir}"
>
<
include
name
="**/*"
/>
</
fileset
>
</
copy
>
<
copy
todir
="${war.dir}"
>
<
fileset
dir
="${views.dir}"
/>
</
copy
>
</
target
>
<
target
name
="updatelib"
depends
="init"
description
="Copies JAR files to WAR directory"
>
<
copy
todir
="${warlib.dir}"
>
<
fileset
dir
="${lib.dir}"
>
<
exclude
name
="*junit*.jar"
/>
<
exclude
name
="*spring-mock*.jar"
/>
</
fileset
>
</
copy
>
</
target
>
<
target
name
="deleteconfig"
depends
="init"
description
="Deletes config files from WAR directory"
>
<
delete
failonerror
="false"
>
<
fileset
dir
="${war.dir}"
>
<
include
name
="**/*.properties"
/>
<
include
name
="**/*.xml"
/>
</
fileset
>
</
delete
>
</
target
>
<
target
name
="updateconfig"
depends
="init,unicode"
description
="Copies configuration files to WAR directory"
>
<
copy
todir
="${class.dir}"
>
<
fileset
dir
="${conf.classes}"
>
<
include
name
="**/*.xml"
/>
<
include
name
="**/*.properties"
/>
<
include
name
="**/*.src"
/>
</
fileset
>
</
copy
>
<
copy
todir
="${webinf.dir}"
preservelastmodified
="true"
>
<
fileset
dir
="${conf.webinf}"
>
<
include
name
="**/*.xml"
/>
<
include
name
="**/*.tld"
/>
</
fileset
>
</
copy
>
</
target
>
<!--
=======================================================
-->
<!--
Compile all classes.
-->
<!--
=======================================================
-->
<
target
name
="compile"
depends
="init"
description
="Compiles .java files to WAR directory"
>
<
javac
srcdir
="${src.dir}"
destdir
="${class.dir}"
encoding
="utf-8"
debug
="on"
deprecation
="yes"
includes
="**"
optimize
="on"
failonerror
="true"
>
<
classpath
refid
="master-classpath"
/>
</
javac
>
</
target
>
<
target
name
="build"
depends
="compile,updateweb,updateconfig,updatelib"
/>
<
target
name
="rebuild"
depends
="clean,compile,updateweb,updateconfig,updatelib"
/>
<
target
name
="dist"
depends
="rebuild"
description
="Assembles WAR file"
>
<
war
destfile
="${war.file}"
webxml
="${conf.webinf}/web.xml"
>
<
fileset
dir
="${war.dir}"
>
<
include
name
="**/*.*"
/>
<
exclude
name
="**/web.xml"
/>
<
exclude
name
="**/test/*.class"
/>
</
fileset
>
</
war
>
</
target
>
<
target
name
="deploy"
depends
="dist"
description
="Deploys WAR file to deploy.dir"
>
<
delete
failonerror
="true"
dir
="${deploy.resin}/${appname}"
/>
<
copy
file
="${war.file}"
todir
="${deploy.resin}"
/>
</
target
>
<!--
=======================================================
-->
<!--
Install targets.
-->
<!--
=======================================================
-->
<
target
name
="resininstall"
>
<
copy
todir
="${deploy.resin}/${appname}"
>
<
fileset
dir
="${war.dir}"
/>
</
copy
>
</
target
>
<
target
name
="resin"
depends
="updateweb, updatelib, updateconfig, resininstall"
/>
<
target
name
="tomcatinstall"
>
<
copy
todir
="${deploy.tomcat}/${appname}"
>
<
fileset
dir
="${war.dir}"
/>
</
copy
>
</
target
>
<
target
name
="tomcat"
depends
="updateweb, updatelib, updateconfig, tomcatinstall"
/>
<!--
=======================================================
-->
<!--
Clean up various files and directories.
-->
<!--
=======================================================
-->
<
target
name
="clean"
description
="Deletes files from WAR directory"
>
<
delete
failonerror
="false"
>
<
fileset
dir
="${war.dir}"
>
<
include
name
="**/*.*"
/>
</
fileset
>
</
delete
>
<
delete
failonerror
="false"
>
<
fileset
dir
="${dist.dir}"
>
<
include
name
="**/*"
/>
</
fileset
>
</
delete
>
<
delete
failonerror
="false"
>
<
fileset
dir
="${dist.dir}"
>
<
include
name
="**/*"
/>
</
fileset
>
</
delete
>
</
target
>
<!--
=======================================================
-->
<!--
Assemble WAR module.
-->
<!--
=======================================================
-->
<
target
name
="unpackwar"
depends
="compile, unicode, updateweb, updatelib, updateconfig"
/>
<!--
<target name="test" depends="unpackwar">
printsummary属性为true会将测试的结果简单的显示出来
<junit printsummary="true" showoutput="yes" filtertrace="false">
<classpath refid="master-classpath" />
batchtest元素定义测试文件以运行(其类名称以Test结尾)
<batchtest fork="yes">
<formatter type="plain" />
<fileset dir="${class.dir}">
<include name="**/*Test.class" />
</fileset>
</batchtest>
</junit>
</target>
-->
<!--
=======================================================
-->
<!--
Compile all testsuite classes.
-->
<!--
=======================================================
-->
<
target
name
="testcompile"
>
<
mkdir
dir
="${test.classesdir}"
/>
<
copy
todir
="${test.classesdir}"
>
<
fileset
dir
="${test.confdir}"
includes
="*.properties"
/>
<
fileset
dir
="${conf.classes}"
includes
="*.*"
excludes
="spring.properties"
/>
</
copy
>
<
javac
encoding
="utf-8"
debug
="on"
deprecation
="yes"
destdir
="${test.classesdir}"
includes
="**"
optimize
="on"
srcdir
="${test.src}"
>
<
classpath
refid
="lib.total"
/>
<
classpath
>
<
pathelement
location
="${class.dir}"
/>
</
classpath
>
</
javac
>
</
target
>
<!--
=======================================================
-->
<!--
Batch Test
-->
<!--
=======================================================
-->
<
target
name
="testAll"
depends
="unpackwar, testcompile"
>
<!--
ant junit
-->
<
mkdir
dir
="${test.reportdir}"
/>
<
junit
printsummary
="no"
fork
="yes"
haltonfailure
="off"
>
<
classpath
>
<
pathelement
location
="${class.dir}"
/>
<
pathelement
location
="${test.classesdir}"
/>
<
pathelement
location
="${conf.webinf}"
/>
<!--
strutsTest must require /WEB-INF/web.xml in classpath
-->
<
pathelement
location
="${war.dir}"
/>
</
classpath
>
<
classpath
refid
="master-classpath"
/>
<
classpath
refid
="test.lib"
/>
<
formatter
type
="xml"
/>
<
formatter
type
="plain"
usefile
="no"
/>
<
test
name
="com.easou.yybar.AllTests"
todir
="${test.reportdir}"
/>
<!--
<batchtest todir="${test.reportdir}">
<fileset dir="${test.classesdir}">
<include name="**/*Test.class" />
<exclude name="**/*TestCase.class" />
<exclude name="**/*$*.class" />
</fileset>
</batchtest>
-->
</
junit
>
</
target
>
<
target
name
="test-reports"
description
="Generate test reports"
>
<
junitreport
todir
="${test.reportdir}"
>
<
fileset
dir
="${test.reportdir}"
>
<
include
name
="TEST-*.xml"
/>
</
fileset
>
<
report
format
="noframes"
todir
="${test.reportdir}"
/>
</
junitreport
>
</
target
>
</
project
>
其目录结构如下:
Tag标签:
Ant
,
Java
,
J2EE
posted on 2008-07-04 11:47
方寸心间
阅读(30)
评论(0)
编辑
收藏
所属分类:
Java
新用户注册
刷新评论列表
标题
姓名
主页
Email
(博主才能看到)
验证码
*
看不清,换一张
[
登录
][
注册
]
内容(请不要发表任何与政治相关的内容)
网站首页
新闻频道
社区
小组
博问
网摘
闪存
找找看
Remember Me?
登录
使用高级评论
新用户注册
返回页首
恢复上次提交
[使用Ctrl+Enter键可以直接提交]
相关文章:
EditPlus v2.12 使用技巧集之工具集成
小菜编程成长记(十三 设计模式不能戏说!设计模式怎就不能戏说?)
Ant使用指南(一)
用C#编写ActiveX控件(一)
Java实现完全开源
Facebook宣布放弃Java支持
Java 的库是用什么语言写的?
抢啊抢,抢沙发!
书籍推荐:《Java数据结构与算法》
10年磨一剑,准备出书《Java组件高级设计》
相关链接:
所属分类的其他文章:
sun jdk,Tomcat在Linux下的安装
【转】P6Spy + SQL Profiler + IronTrackSQL【修改】
工具类:DateUtils类提供日期的处理方法
工具类:统计在线人数
【转】华为的JAVA面试题
【转】华为Java笔试题
struts2中struts.properties属性详解
java常见错误以及可能原因
在Hibernate中配置多对多连接表
在Hibernate中配置一对多连接表
最新IT新闻:
开心网即将启用”shejiao.com”?
Google股价跌破329美元 61%员工期权价值归零
十年祭:昔日明星软件今何在?
六大可能出售IT企业名单:SUN领头或被猎走
Linux内核2.6.27正式到来
<
2008年7月
>
日
一
二
三
四
五
六
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3