-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.xml
129 lines (115 loc) · 4.07 KB
/
build.xml
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="help" name="DBExplorer">
<description>LBS</description>
<!-- 外部属性装载 -->
<property file="ant.properties" />
<!-- web资源目录 -->
<property name="web.dir" value="web" />
<!-- java源代码目录 -->
<property name="src.dir" value="src" />
<!-- jar包位置 -->
<property name="lib.dir" value="${web.dir}/WEB-INF/lib" />
<!-- 部署目录 -->
<property name="deploy.dir" value="${webapp.dir}/${ant.project.name}" />
<!-- out.dir.base -->
<property name="out.base" value="${export.dir}/${ant.project.name}" />
<!-- 发布输出目录 -->
<property name="dist.dir" value="${out.base}/dist" />
<!-- 编译结果输出目录 -->
<property name="out.dir" value="${out.base}/build" />
<!-- class编译输出目录 -->
<property name="build.out" value="${out.dir}/WEB-INF/classes" />
<!-- classpath定义 -->
<path id="app.class.path">
<pathelement location="${build.out}" />
<pathelement path="${j2ee.jar.files}" />
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
</path>
<!-- =================================
target: 显示Ant任务帮助
================================= -->
<target description="帮助" name="help" depends="init">
<echo message="ant -p :显示帮助信息" />
</target>
<!-- =================================
target: 部署到应用目录
================================= -->
<target name="deploy" depends="compiler" description="部署">
<mkdir dir="${deploy.dir}" />
<copy todir="${deploy.dir}">
<fileset dir="${out.dir}">
<include name="*/**" />
</fileset>
</copy>
<echo message="部署系统 To ${deploy.dir}" />
</target>
<!-- =================================
target: 撤销部署
================================= -->
<target name="undeploy" depends="init" description="反部署">
<delete dir="${deploy.dir}" />
</target>
<!-- =================================
target: 清理编译结果
================================= -->
<target name="cleanup" depends="init" description="清理">
<delete dir="${out.dir}" />
</target>
<!-- =================================
target: 输出应用为war文件
================================= -->
<target name="dist" depends="compiler" description="发布">
<mkdir dir="${dist.dir}" />
<jar destfile="${dist.dir}/${ant.project.name}.war">
<fileset dir="${out.dir}">
<include name="*/**" />
</fileset>
</jar>
<echo message="输出war文件 To ${dist.dir}/${ant.project.name}.war" />
</target>
<!-- target: 打包源代码-->
<target name="dist-src" depends="init" description="打包源代码">
<mkdir dir="${dist.dir}" />
<zip destfile="${dist.dir}/${ant.project.name}-src.zip">
<zipfileset dir="${src.dir}" prefix="src" />
<zipfileset dir="${web.dir}" prefix="WebContent" />
<fileset dir=".">
<include name="build.xml" />
<include name="ant.properties" />
</fileset>
</zip>
</target>
<!-- target: 编译 -->
<target name="compiler" depends="init">
<mkdir dir="${out.dir}" />
<!-- copy web资源文件-->
<copy todir="${out.dir}">
<fileset dir="${web.dir}">
<include name="*/**" />
</fileset>
</copy>
<!-- 编译源文件 -->
<mkdir dir="${build.out}" />
<javac srcdir="${src.dir}" fork="${fork.option}" optimize="${optimize.option}" nowarn="${nowarn.option}" destdir="${build.out}" encoding="${source.encoding}" debug="${debug.option}" source="${source.version}" target="${target.version}">
<classpath refid="app.class.path" />
</javac>
<!-- copy 属性文件-->
<copy todir="${build.out}">
<fileset dir="${src.dir}">
<exclude name="**/*.java" />
</fileset>
</copy>
<echo message="编译输出 To ${out.dir}" />
</target>
<!-- target: 初始化 -->
<target name="init">
<tstamp>
<format property="my.today" pattern="yyyy-MM-dd HH:mm:ss" />
</tstamp>
<echo message="ANT :${ant.version}" />
<echo message="JAVA:${java.vm.name} ${java.version}" />
<echo message="Time:${my.today}" />
</target>
</project>