ANT build.xml文件详解
?
一个ant的build.xml文件实例
01
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
02
<
project
name
=
"dian_bid"
basedir
=
"."
default
=
"deploy"
>
03
?
?04
?
<
property
name
=
"source"
location
=
"src"
/>
05
?
<
property
name
=
"resource"
location
=
"res"
/>
06
?
<
property
name
=
"test-srouce"
location
=
"test"
/>
07
?
<
property
name
=
"release-resource"
location
=
"release"
/>
08
?
<
property
name
=
"dest"
location
=
"dest"
/>
09
?
?10
?
<
property
name
=
"webroot"
location
=
"web"
/>
11
?
<
property
name
=
"tomcat-root"
location
=
"D:/Java/apache-tomcat-a"
/>
12
?
?13
?
<
target
name
=
"clean"
>
14
??
<
echo
message
=
"清理生成过程中的临时文件"
/>
15
??
<
delete
dir
=
"${tomcat-root}/webapps/bid"
/>
16
??
<
delete
dir
=
"${webroot}/WEB-INF/classes"
/>
17
??
<
delete
dir
=
"${dest}"
/>
18
?
</
target
>
19
?
?20
?
<
target
name
=
"prepare"
depends
=
"clean"
>
21
??
<
mkdir
dir
=
"${webroot}/WEB-INF/classes"
/>
22
??
<
mkdir
dir
=
"${dest}"
/>
23
?
</
target
>
24
?
?25
?
<
target
name
=
"build"
depends
=
"prepare"
>
26
??
<
echo
message
=
"编译Java源代码"
/>
27
??
<
javac
destdir
=
"${webroot}/WEB-INF/classes"
srcdir
=
"${source}"
>
28
???
<
sourcepath
path
=
"${test-srouce}"
/>
29
???
<
classpath
>
30
????
<
fileset
dir
=
"${tomcat-root}/lib"
>
31
?????
<
include
name
=
"**/*.jar"
/>
32
????
</
fileset
>
33
????
<
fileset
dir
=
"${webroot}/WEB-INF/lib"
>
34
?????
<
include
name
=
"**/*.jar"
/>
35
????
</
fileset
>
36
???
</
classpath
>
37
??
</
javac
>
38
?
</
target
>
39
?
?40
?
<
target
name
=
"package"
depends
=
"build"
>
41
??
<
echo
message
=
"将Web工程打包成war可部署文件格式"
/>
42
??
<
copydir
dest
=
"${webroot}/WEB-INF/classes"
src
=
"${resource}"
/>
43
??
<
copydir
dest
=
"${webroot}/WEB-INF/classes"
src
=
"${release-resource}"
/>
44
??
<
war
destfile
=
"${dest}/bid.war"
? basedir
=
"${webroot}"
webxml
=
"${webroot}/WEB-INF/web.xml"
/>
45
?
</
target
>
46
?
?47
?
<
target
name
=
"deploy"
depends
=
"package"
>
48
??
<
echo
message
=
"开始部署BID系统到服务器上"
/>
49
??
<
copy
file
=
"${dest}/bid.war"
todir
=
"${tomcat-root}/webapps"
/>
50
??
<
echo
message
=
"停止tomcat服务器"
/>
51
??
<
exec
executable
=
"${tomcat-root}/bin/shutdown.bat"
/>
52
??
<
echo
message
=
"启动tomcat服务器"
/>
53
??
<
exec
executable
=
"${tomcat-root}/bin/startup.bat"
/>
54
??
<
echo
message
=
"部署BID系统完成"
/>
55
?
</
target
>
56
</
project
>