没有比人更高的山

一个ant的build.xml文件实例0

很简单,很实用,写完之后,发现,嘿嘿!我居然可以不翻doc写build文件了。

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?xml version="1.0" encoding="utf-8" ?>
<project name="dian_bid" basedir="." default="deploy">
 
 <property name="source" location="src" />
 <property name="resource" location="res" />
 <property name="test-srouce" location="test" />
 <property name="release-resource" location="release" />
 <property name="dest" location="dest" />
 
 <property name="webroot" location="web"/>
 <property name="tomcat-root" location="D:/Java/apache-tomcat-a"/>
 
 <target name="clean">
  <echo message="清理生成过程中的临时文件" />
  <delete dir="${tomcat-root}/webapps/bid" />
  <delete dir="${webroot}/WEB-INF/classes" />
  <delete dir="${dest}" />
 </target>
 
 <target name="prepare" depends="clean">
  <mkdir dir="${webroot}/WEB-INF/classes"/>
  <mkdir dir="${dest}" />
 </target>
 
 <target name="build" depends="prepare">
  <echo message="编译Java源代码" />
  <javac destdir="${webroot}/WEB-INF/classes" srcdir="${source}">
   <sourcepath path="${test-srouce}" />
   <classpath>
    <fileset dir="${tomcat-root}/lib">
     <include name="**/*.jar"/>
    </fileset>
    <fileset dir="${webroot}/WEB-INF/lib">
     <include name="**/*.jar"/>
    </fileset>
   </classpath>
  </javac>
 </target>
 
 <target name="package" depends="build">
  <echo message="将Web工程打包成war可部署文件格式" />
  <copydir dest="${webroot}/WEB-INF/classes" src="${resource}" />
  <copydir dest="${webroot}/WEB-INF/classes" src="${release-resource}" />
  <war destfile="${dest}/bid.war"  basedir="${webroot}" webxml="${webroot}/WEB-INF/web.xml"/>
 </target>
 
 <target name="deploy" depends="package">
  <echo message="开始部署BID系统到服务器上" />
  <copy file="${dest}/bid.war" todir="${tomcat-root}/webapps" />
  <echo message="停止tomcat服务器" />
  <exec executable="${tomcat-root}/bin/shutdown.bat" />
  <echo message="启动tomcat服务器" />
  <exec executable="${tomcat-root}/bin/startup.bat" />
  <echo message="部署BID系统完成" />
 </target>
</project>
VN:F [1.7.5_995]
Rating: 8.5/10 (2 votes cast)
VN:F [1.7.5_995]
Rating: 0 (from 2 votes)