-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
150 lines (132 loc) · 5.15 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?xml version="1.0" encoding="utf-8"?>
<!--
Default build.xml file for JavaWeb Project
==========================================
@depend ant-1.9.2+ (tested, actually more below this)
@author "galin"<[email protected]>
@version 1.3.1 build 2014/2/15
==========================================
You can do whatever to this file as you wish.
This file and other attachement is provided as-if, and no warranty.
==========================================
[USAGE]
Config your project-name right below, then paste it to your project-base. use 'ant -projecthelp' to view all commands.
-->
<project name="watermeter" basedir="." default="build-all" >
<!-- 变量 -->
<property name="srcdir" value="src" />
<property name="dtlibdir" value="lib" />
<property name="webdir" value="web" />
<property name="javadocdir" value="javadoc" />
<property name="webinfdir" value="${webdir}/WEB-INF" />
<property name="rtlibdir" value="${webinfdir}/lib" />
<property name="destdir" value="${webinfdir}/classes" />
<path id="classpath">
<fileset id="rt-packages" dir="${rtlibdir}">
<include name="*.jar" />
</fileset>
<fileset id="dt-packages" dir="${dtlibdir}">
<include name="*.jar" />
</fileset>
<pathelement path="${destdir}" />
</path>
<pathconvert property="webdir.absolute">
<path location="${basedir}\${webdir}" />
</pathconvert>
<!-- 初始化目录树 -->
<target name="init" description="初始化目录树及默认配置文件, 注意会覆盖 web.xml">
<mkdir dir="${srcdir}" />
<mkdir dir="${dtlibdir}" />
<mkdir dir="${rtlibdir}" />
<mkdir dir="${destdir}" />
<antcall target="init-genwebxml" />
<antcall target="init-gendeploy" />
</target>
<target name="init-genwebxml" description="初始化默认的 web.xml">
<echo file="${webinfdir}/web.xml"><?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:web="http://java.sun.com/xml/ns/javaee"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>${ant.project.name}</display-name>
<!--
<servlet>
<servlet-name></servlet-name>
<servlet-class></servlet-class>
</servlet>
<servlet-mapping>
<servlet-name></servlet-name>
<url-pattern></url-pattern>
</servlet-mapping>
-->
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
</echo>
</target>
<target name="init-gendeploy" description="生成指向配置文件, 用于 tomcat 的引用部署">
<echo file="${ant.project.name}.xml"><!-- note: copy this file to your TOMCAT_HOME/conf/Catalina/localhost(or other as your actual) to deploy -->
<Context docBase="${webdir.absolute}">
</Context>
</echo>
</target>
<!-- 编译 -->
<target name="build" description="编译">
<mkdir dir="${destdir}" />
<antcall target="copy-config" />
<javac srcdir="${srcdir}" destdir="${destdir}" failonerror="true" debug="true" includeantruntime="false" encoding="utf-8">
<compilerarg value="-Xlint:unchecked"/>
<classpath refid="classpath" />
</javac>
</target>
<target name="clear-built" description="清理">
<delete>
<fileset dir="${destdir}" includes="**/*"/>
</delete>
</target>
<target name="build-all" description="全部重新编译">
<antcall target="clear-built" />
<antcall target="build" />
</target>
<target name="copy-config" description="复制配置文件">
<copy todir="${destdir}">
<fileset dir="${srcdir}">
<include name="realm*" />
<include name="**/*.xml" />
<include name="**/*.properties" />
</fileset>
</copy>
</target>
<!-- 生成javadoc -->
<target name="javadoc" description="生成javadoc">
<javadoc sourcepath="${srcdir}" destdir="${javadocdir}" private="true" classpathref="classpath" encoding="utf-8" />
</target>
<!-- 生成war -->
<target name="war" description="生成war">
<antcall target="build-all"/>
<jar destfile="${ant.project.name}.war" basedir="${webdir}" />
</target>
<!-- 调试 -->
<target name="debug" description="本地测试, 使用-Ddebug.main=<类名>指定jvm的入口类">
<java classname="${debug.main}" fork="true" dir="${destdir}">
<!-- 启用断言 -->
<jvmarg value="-ea" />
<!-- 启用调试 -->
<jvmarg value="-Xdebug"/>
<!-- 启用远程调试 -->
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=8288,suspend=y,server=y"/>
<classpath refid="classpath" />
</java>
</target>
<!-- 运行 -->
<target name="run" description="直接运行, 使用-Drun.main=<类名>指定入口类">
<java classname="${run.main}" fork="true" dir="${destdir}">
<classpath refid="classpath" />
</java>
</target>
<!-- 工具集 -->
</project>