forked from nutzam/nutz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild2.xml
228 lines (204 loc) · 8.95 KB
/
build2.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<?xml version="1.0" encoding="UTF-8"?>
<project name="nutz" default="run" basedir="../">
<description>
用于构建快照版,稍作修改也可用于正式版的构建
By wendal (wendal1985@gmail.com)
说明:
1. 用于构建正式版时,修改nutz.jar.pre
本构建用来生成一个 zip 包,其中包括
* API 文档
* JDK1.5 版本 jar
* JDK1.6 版本 jar
* JUnit 测试结果
* Emma 代码覆盖率报告
* 用户手册(中英文,html文件)
build/deps 包含了所有依赖 jar,它们应该包括:
1. log4j 1.2.12+ 以及 log4j.properties
2. JUnit 4
3. Nutzdoc 1.7
4. Servlet-API 2.4+
5. nutz-test.properties 以及其相应的数据库驱动(默认是H2)
6. commons-dbcp
7. commons-pool
8. emma 用于生成代码覆盖率报告
9. JDiff 生成API差异报告,外加旧版本的源文件一份,解压到build/oldsrc
环境变量 ${OUTPUT} 声明了 zip 文件包的输出位置
构建结束后,会删除所有临时文件
</description>
<property environment="env" />
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
<property name="OUTPUT" value="." />
<property name="nutz-version" value="1.r.54" />
<tstamp>
<format property="now-date" locale="en" pattern="yyyyMMdd_hhmmaa" timezone="Asia/Shanghai" />
</tstamp>
<property name="tmp-dir" value="build/tmp" />
<property name="pub-dir" value="build/pub" />
<property name="classes-dir-jdk5" value="${tmp-dir}/jdk5" />
<property name="classes-dir-jdk6" value="${tmp-dir}/jdk6" />
<property name="classes-dir-test" value="${tmp-dir}/test" />
<property name="classes-dir-emma" value="${tmp-dir}/emma" />
<property name="javadoc-dir" value="${pub-dir}/api" />
<property name="tmp-junitreport-dir" value="${tmp-dir}/junit-report" />
<property name="pub-junitreport-dir" value="${pub-dir}/junit-report" />
<property name="zdoc-dir" value="${pub-dir}/manual" />
<property name="zdoc-en-dir" value="${pub-dir}/manual_en" />
<!--property name="nutz.dest.pre" value="nutz-${nutz-version}-snapshot-${now-date}" /-->
<property name="nutz.dest.pre" value="nutz-${nutz-version}"></property>
<!-- 用于正式版 -->
<property name="nutz.jar.source" value="${pub-dir}/${nutz.dest.pre}-sources.jar" />
<property name="nutz.jar.jdoc" value="${pub-dir}/${nutz.dest.pre}-javadoc.jar" />
<property name="nutz.jar.jdk5" value="${pub-dir}/${nutz.dest.pre}-jdk5.jar" />
<property name="nutz.jar.jdk6" value="${pub-dir}/${nutz.dest.pre}.jar" />
<property name="nutz.manual.pdf" value="${pub-dir}/${nutz.dest.pre}-manual.pdf" />
<property name="nutz.manual_en.pdf" value="${pub-dir}/${nutz.dest.pre}-manual_en.pdf" />
<property name="nutz.manual.rtf" value="${pub-dir}/${nutz.dest.pre}-manual.rtf" />
<property name="nutz.manual_en.rtf" value="${pub-dir}/${nutz.dest.pre}-manual_en.rtf" />
<property name="nutz.pub.zip" value="${OUTPUT}/${nutz.dest.pre}.zip" />
<!-- 启用emma? -->
<property name="emma.enabled" value="true" />
<path id="nutz-classpath">
<pathelement location="${basedir}/build/deps" />
<path>
<fileset dir="${basedir}/build/deps" includes="**/*.jar" />
</path>
<pathelement location="${JAVA_HOME}/lib/tools.jar" />
</path>
<taskdef resource="emma_ant.properties" classpathref="nutz-classpath" />
<target name="clean">
<delete dir="${tmp-dir}" />
<delete dir="${pub-dir}" />
</target>
<target name="init">
<mkdir dir="${tmp-dir}" />
<mkdir dir="${classes-dir-jdk5}" />
<mkdir dir="${classes-dir-jdk6}" />
<mkdir dir="${classes-dir-test}" />
<mkdir dir="${classes-dir-emma}" />
<mkdir dir="${tmp-junitreport-dir}" />
<mkdir dir="${pub-dir}" />
<mkdir dir="${pub-junitreport-dir}" />
<mkdir dir="${pub-dir}/emma" />
<mkdir dir="${javadoc-dir}" />
<mkdir dir="${zdoc-dir}" />
<mkdir dir="${zdoc-en-dir}" />
</target>
<target name="create-jar">
<jar destfile="${nutz.jar.source}" basedir="src" encoding="utf-8" />
<javac compiler="org.eclipse.jdt.core.JDTCompilerAdapter" destdir="${classes-dir-jdk5}" debuglevel="lines,vars,source" debug="true" srcdir="src" source="1.5" target="1.5" encoding="utf-8" classpathref="nutz-classpath" includeantruntime="false" />
<copy todir="${classes-dir-jdk5}">
<fileset file="License.txt" />
<fileset dir="src" excludes="**/*.java" />
</copy>
<jar destfile="${nutz.jar.jdk5}" basedir="${classes-dir-jdk5}" index="true" />
<javac compiler="org.eclipse.jdt.core.JDTCompilerAdapter" destdir="${classes-dir-jdk6}" debuglevel="lines,vars,source" debug="true" srcdir="src" source="1.6" target="1.6" encoding="utf-8" classpathref="nutz-classpath" includeantruntime="false" />
<copy todir="${classes-dir-jdk6}">
<fileset file="License.txt" />
<fileset dir="src" excludes="**/*.java" />
</copy>
<jar destfile="${nutz.jar.jdk6}" basedir="${classes-dir-jdk6}" index="true" />
</target>
<target name="test">
<emma enabled="${emma.enabled}">
<instr instrpath="${classes-dir-jdk6}" destdir="${classes-dir-emma}" metadatafile="${classes-dir-emma}/metadata.emma" merge="true">
<filter excludes="org.nutz.repo.*" />
</instr>
</emma>
<javac destdir="${classes-dir-test}" debuglevel="lines,vars,source" debug="true" srcdir="test" source="1.6" target="1.6" encoding="utf-8" includeantruntime="false">
<classpath>
<path path="${classes-dir-jdk6}" />
<path refid="nutz-classpath" />
</classpath>
</javac>
<copy todir="${classes-dir-test}">
<fileset excludes="**/*.java" dir="test" />
</copy>
<junit fork="true" showoutput="true" printsummary="yes" filtertrace="true" maxmemory="256M" haltonerror="false" haltonfailure="false">
<classpath>
<path path="${classes-dir-emma}" />
<path path="${classes-dir-jdk6}" />
<path path="${classes-dir-test}" />
<path refid="nutz-classpath" />
</classpath>
<batchtest todir="${tmp-junitreport-dir}">
<fileset dir="test">
<include name="**/*Test.java" />
</fileset>
<formatter type="xml" />
</batchtest>
<jvmarg value="-Demma.coverage.out.file=${basedir}/${classes-dir-emma}/session.emma" />
<jvmarg value="-Demma.coverage.out.merge=true" />
</junit>
<junitreport todir="${pub-junitreport-dir}">
<report format="frames" todir="${pub-junitreport-dir}" />
<fileset dir="${tmp-junitreport-dir}" includes="*.xml" />
</junitreport>
<emma enabled="${emma.enabled}">
<report sourcepath="src" encoding="utf-8">
<fileset dir="${classes-dir-emma}">
<include name="*.emma" />
</fileset>
<html outfile="${basedir}/${pub-dir}/emma/coverage.html" />
<txt outfile="${basedir}/${pub-dir}/emma/coverage.txt" />
</report>
</emma>
</target>
<target name="jdoc">
<javadoc sourcepath="src" classpathref="nutz-classpath" encoding="UTF-8" destdir="${javadoc-dir}" charset="utf-8" docencoding="utf-8" />
<jar destfile="${nutz.jar.jdoc}">
<fileset dir="${javadoc-dir}" />
</jar>
</target>
<target name="manual">
<taskdef resource="zdoc_ant.properties">
<classpath path="${classes-dir-jdk6}" />
<classpath path="${classes-dir-emma}" />
<classpath path="${classes-dir-test}" />
<classpath refid="nutz-classpath" />
</taskdef>
<echo>Build Html manual for CN</echo>
<zdoc suffix="html" src="${basedir}/doc/manual" dest="${basedir}/${zdoc-dir}" />
<echo>Build Html manual for EN</echo>
<zdoc suffix="html" src="${basedir}/doc/manual_en" dest="${basedir}/${zdoc-en-dir}" />
<echo>Build PDF manual for CN</echo>
<zdoc suffix="pdf" src="${basedir}/doc/manual" dest="${basedir}/${nutz.manual.pdf}" />
<echo>Build PDF manual for EN</echo>
<zdoc suffix="pdf" src="${basedir}/doc/manual_en" dest="${basedir}/${nutz.manual_en.pdf}" />
<echo>Build RTF manual for CN</echo>
<zdoc suffix="rtf" src="${basedir}/doc/manual" dest="${basedir}/${nutz.manual.rtf}" />
<echo>Build RTF manual for EN</echo>
<zdoc suffix="rtf" src="${basedir}/doc/manual_en" dest="${basedir}/${nutz.manual_en.rtf}" />
</target>
<!-- =================================
target: jdiff
================================= -->
<target name="jdiff">
<property name="JDIFF_HOME" value="${basedir}/build/deps" />
<taskdef name="jdiff" classname="jdiff.JDiffAntTask" classpathref="nutz-classpath" />
<mkdir dir="${pub-dir}/jdiff" />
<jdiff destdir="${pub-dir}/jdiff" verbose="on" stats="on" docchanges="off">
<new name="${nutz-version}" encoding="UTF-8">
<!-- This is the location of your new source files -->
<dirset dir="${basedir}/src" excludes="**/repo/org/**" />
</new>
<old name="1.b.35" encoding="UTF-8">
<!-- This is the location of your old source files -->
<dirset dir="${basedir}/build/oldsrc/" excludes="**/repo/org/**" />
</old>
</jdiff>
</target>
<target name="create-zip">
<zip destfile="${nutz.pub.zip}">
<fileset dir="${pub-dir}" />
</zip>
</target>
<target name="run">
<antcall target="clean" />
<antcall target="init" />
<antcall target="create-jar" />
<antcall target="jdoc" />
<antcall target="manual" />
<antcall target="create-zip" />
<antcall target="clean" />
</target>
</project>