-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.xml
407 lines (363 loc) · 18 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
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Build file for Tomcat Native -->
<project name="Tomcat Native" default="compile" basedir=".">
<!-- Give user a chance to override without editing this file
(and without typing -D each time it compiles it
-->
<property file="${user.home}/.ant.properties" />
<property file="${user.home}/build.properties" />
<property file=".ant.properties" />
<property file="build.properties" />
<property file="build.properties.default"/>
<!-- Initialization properties -->
<property name="project" value="tomcat-native" />
<property name="name" value="Tomcat Native" />
<property name="title" value="Tomcat Native Library"/>
<property name="year" value="2020" />
<property name="test.runner" value="junit.textui.TestRunner"/>
<property name="version" value="${version.major}.${version.minor}.${version.build}${version.suffix}" />
<property name="version.number" value="${version.major}.${version.minor}.${version.build}.${version.patch}" />
<property name="version.major.minor" value="${version.major}.${version.minor}" />
<property name="final.name" value="${project}-${version}" />
<property name="build.dir" value="./dist"/>
<property name="build.src" value="${build.dir}/src"/>
<property name="build.dest" value="${build.dir}/classes"/>
<property name="src.dir" value="."/>
<property name="dist.root" value="./dist"/>
<property name="ant.home" value="."/>
<property name="docs.src" value="./xdocs"/>
<property name="docs.dest" value="${dist.root}/doc"/>
<property name="docs.dest.print" value="${dist.root}/doc/printable"/>
<property name="test.dir" value="${build.dest}/test"/>
<property name="examples.dir" value="${build.dest}/examples"/>
<property name="tc.library.path" value="${basedir}/native/.libs"/>
<!-- The base directory for component sources -->
<property name="source.home" value="java"/>
<!-- Tests To Run -->
<property name="test.name" value="**/Test*.java"/>
<!-- Build classpath -->
<path id="classpath">
<pathelement location="${build.dest}/java"/>
</path>
<!-- Test classpath -->
<path id="test.classpath">
<pathelement location="${build.dest}/java"/>
<pathelement location="${build.dest}/test"/>
<pathelement location="${junit.jar}"/>
<pathelement location="${hamcrest.jar}"/>
</path>
<!-- Examples classpath -->
<path id="examples.classpath">
<pathelement location="${build.dest}/java"/>
<pathelement location="${build.dest}/examples"/>
</path>
<!-- =================================================================== -->
<!-- prints the environment -->
<!-- =================================================================== -->
<target name="env">
<echo message="java.home = ${java.home}"/>
<echo message="user.home = ${user.home}"/>
<!--
<echo message="java.class.path = ${java.class.path}"/>
-->
<echo message="tc.library.path = ${tc.library.path}"/>
<echo message=""/>
</target>
<target name="prepare" depends="env">
<mkdir dir="${build.dir}"/>
<mkdir dir="${basedir}/logs"/>
</target>
<!-- Download and dependency building -->
<target name="proxyflags">
<!-- check proxy parameters. -->
<condition property="useproxy">
<equals arg1="${proxy.use}" arg2="on" />
</condition>
</target>
<target name="setproxy" depends="proxyflags" if="useproxy">
<taskdef name="setproxy"
classname="org.apache.tools.ant.taskdefs.optional.net.SetProxy" />
<setproxy proxyhost="${proxy.host}" proxyport="${proxy.port}"
proxyuser="${proxy.user}" proxypassword="${proxy.password}" />
<echo message="Using ${proxy.host}:${proxy.port} to download ${sourcefile}"/>
</target>
<target name="testexist">
<echo message="Testing for ${destfile}"/>
<available file="${destfile}" property="exist"/>
</target>
<target name="downloadgz" unless="exist" depends="setproxy,testexist">
<!-- Download and extract the package -->
<get src="${sourcefile}" dest="${base.path}/file.tar.gz" />
<gunzip src="${base.path}/file.tar.gz" dest="${base.path}/file.tar"/>
<untar src="${base.path}/file.tar" dest="${base.path}"/>
<delete file="${base.path}/file.tar"/>
<delete file="${base.path}/file.tar.gz"/>
</target>
<target name="downloadzip" unless="exist" depends="setproxy,testexist">
<!-- Download and extract the package -->
<get src="${sourcefile}" dest="${base.path}/file.zip" />
<mkdir dir="${destdir}" />
<unzip src="${base.path}/file.zip" dest="${destdir}"/>
<delete file="${base.path}/file.zip"/>
</target>
<target name="downloadfile" unless="exist" depends="setproxy,testexist">
<!-- Download extract the file -->
<mkdir dir="${destdir}" />
<get src="${sourcefile}" dest="${destfile}" />
</target>
<target name="download" description="Download needed dependencies">
<mkdir dir="${base.path}"/>
<antcall target="downloadfile">
<param name="sourcefile" value="${junit.loc}"/>
<param name="destfile" value="${junit.jar}"/>
<param name="destdir" value="${junit.home}"/>
</antcall>
<antcall target="downloadfile">
<param name="sourcefile" value="${hamcrest.loc}"/>
<param name="destfile" value="${hamcrest.jar}"/>
<param name="destdir" value="${hamcrest.home}"/>
</antcall>
</target>
<!-- =================================================================== -->
<!-- Creates the API documentation -->
<!-- =================================================================== -->
<target name="javadocs" description="Java documentation">
<mkdir dir="${docs.dest}"/>
<mkdir dir="${docs.dest}/api"/>
<javadoc sourcepath="${build.src}/java"
destdir="${docs.dest}/api"
author="true"
version="true"
overview="${src.dir}/java/overview.html"
packagenames="org.apache.tomcat.*"
windowtitle="${title} (Version ${version})"
doctitle="<h1>${title} (Version ${version})</h1>"
bottom="Copyright 2002-2020 The Apache Software Foundation.<!--
Licensed under the Apache License, Version 2.0 (the 'License');
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an 'AS IS' BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.-->">
<classpath refid="classpath"/>
</javadoc>
</target>
<!-- =================================================================== -->
<!-- Cleans up the build directory -->
<!-- =================================================================== -->
<target name="clean" description="Clean build directory">
<delete dir="${build.dir}"/>
</target>
<!-- =================================================================== -->
<!-- Compiles the source directory -->
<!-- =================================================================== -->
<target name="compile" depends="prepare" description="Compile Java sources">
<mkdir dir="${build.dest}"/>
<mkdir dir="${build.dest}/java"/>
<mkdir dir="${build.src}"/>
<mkdir dir="${build.src}/java"/>
<tstamp>
<format property="TODAY" pattern="MMM d yyyy" locale="en"/>
<format property="TSTAMP" pattern="hh:mm:ss"/>
</tstamp>
<!-- Copy static resource files -->
<filter token="VERSION" value="${version}"/>
<filter token="VERSION_NUMBER" value="${version.number}"/>
<filter token="VERSION_BUILT" value="${TODAY} ${TSTAMP}"/>
<copy todir="${build.src}/java" filtering="yes" encoding="ISO-8859-1">
<fileset dir="${src.dir}/java">
<include name="**/*.java"/>
<include name="**/*.xml"/>
<include name="**/*.properties"/>
</fileset>
</copy>
<javac srcdir="${build.src}/java"
destdir="${build.dest}/java"
source="${compile.source}"
target="${compile.target}"
debug="${compile.debug}"
deprecation="${compile.deprecation}"
optimize="${compile.optimize}"
encoding="ISO-8859-1"
includeantruntime="false">
<classpath refid="classpath"/>
</javac>
<copy todir="${build.dest}/java" filtering="yes" encoding="ISO-8859-1">
<fileset dir="${build.src}/java">
<include name="**/*.xml"/>
<include name="**/*.properties"/>
</fileset>
</copy>
</target>
<!-- ================================================================== -->
<!-- Make Tomcat Native jar -->
<!-- ================================================================== -->
<target name="jar" depends="compile" description="Generates the Jar file">
<jar
destfile="${build.dir}/${final.name}.jar"
basedir="${build.dir}/classes/java"
excludes="**/*.java">
<manifest>
<section name="org/apache/tomcat/jni">
<attribute name="Specification-Title" value="Tomcat Native"/>
<attribute name="Specification-Version" value="${version}"/>
<attribute name="Specification-Vendor" value="Apache Software Foundation"/>
<attribute name="Implementation-Title" value="org.apache.tomcat.jni"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
<attribute name="Implementation-Vendor-Id" value="org.apache"/>
<attribute name="Implementation-Version" value="${version} (build ${DSTAMP} ${TSTAMP})"/>
</section>
</manifest>
</jar>
</target>
<!-- =================================================================== -->
<!-- Compiles the test directory -->
<!-- =================================================================== -->
<target name="compile-tests" depends="compile" description="Compile Java test classes">
<mkdir dir="${build.dest}"/>
<mkdir dir="${build.dest}/test"/>
<mkdir dir="${build.src}"/>
<mkdir dir="${build.src}/test"/>
<tstamp>
<format property="TODAY" pattern="MMM d yyyy" locale="en"/>
<format property="TSTAMP" pattern="hh:mm:ss"/>
</tstamp>
<!-- Copy static resource files -->
<filter token="VERSION" value="${version}"/>
<filter token="VERSION_NUMBER" value="${version.number}"/>
<filter token="VERSION_BUILT" value="${TODAY} ${TSTAMP}"/>
<copy todir="${build.src}/test" filtering="yes" encoding="ISO-8859-1">
<fileset dir="${src.dir}/test">
<include name="**/*.java"/>
<include name="**/*.xml"/>
<include name="**/*.properties"/>
</fileset>
</copy>
<javac srcdir="${build.src}/test"
destdir="${build.dest}/test"
source="${compile.source}"
target="${compile.target}"
debug="on"
deprecation="${compile.deprecation}"
optimize="${compile.optimize}"
encoding="ISO-8859-1"
includeantruntime="false">
<classpath refid="test.classpath"/>
</javac>
<copy todir="${build.dest}/test" filtering="yes" encoding="ISO-8859-1">
<fileset dir="${build.src}/test">
<include name="**/*.xml"/>
<include name="**/*.properties"/>
</fileset>
</copy>
</target>
<!-- =================================================================== -->
<!-- Junit tests -->
<!-- =================================================================== -->
<target name="test" depends="compile-tests" description="Run the tests">
<echo message="Running Tomcat Native package tests ..."/>
<junit printsummary="yes" fork="yes" dir="." showoutput="yes"
haltonfailure="${test.failonerror}" >
<formatter type="plain"/>
<jvmarg value="-Djava.library.path=${tc.library.path}"/>
<classpath refid="test.classpath" />
<batchtest todir="${basedir}/logs">
<!-- Include all by default -->
<fileset dir="test" includes="${test.name}">
<!-- Exclude helper classes -->
<exclude name="**/Tester*.java" />
</fileset>
</batchtest>
</junit>
</target>
<!-- =================================================================== -->
<!-- Compiles the examples directory -->
<!-- =================================================================== -->
<target name="compile-examples" depends="compile" description="Compile example Java classes">
<mkdir dir="${build.dest}"/>
<mkdir dir="${build.dest}/examples"/>
<mkdir dir="${build.src}"/>
<mkdir dir="${build.src}/examples"/>
<tstamp>
<format property="TODAY" pattern="MMM d yyyy" locale="en"/>
<format property="TSTAMP" pattern="hh:mm:ss"/>
</tstamp>
<!-- Copy static resource files -->
<filter token="VERSION" value="${version}"/>
<filter token="VERSION_NUMBER" value="${version.number}"/>
<filter token="VERSION_BUILT" value="${TODAY} ${TSTAMP}"/>
<copy todir="${build.src}/examples" filtering="yes" encoding="ISO-8859-1">
<fileset dir="${src.dir}/examples">
<include name="**/*.java"/>
<include name="**/*.xml"/>
<include name="**/*.properties"/>
</fileset>
</copy>
<javac srcdir="${build.src}/examples"
destdir="${build.dest}/examples"
source="${compile.source}"
target="${compile.target}"
debug="${compile.debug}"
deprecation="${compile.deprecation}"
optimize="${compile.optimize}"
encoding="ISO-8859-1">
<classpath refid="examples.classpath"/>
</javac>
<copy todir="${build.dest}/examples" filtering="yes" encoding="ISO-8859-1">
<fileset dir="${build.src}/examples">
<include name="**/*.xml"/>
<include name="**/*.properties"/>
</fileset>
</copy>
</target>
<!-- =================================================================== -->
<!-- executes the examples -->
<!-- =================================================================== -->
<target name="run-echo" depends="compile-examples" description="Run the Echo example">
<echo message="Running Tomcat Native Echo example ..."/>
<java dir="${examples.dir}" classname="org.apache.tomcat.jni.Echo"
fork="yes" failonerror="${test.failonerror}">
<classpath refid="examples.classpath"/>
<env key="PATH" path="${tc.library.path}:${java.library.path}"/>
<env key="Path" path="${tc.library.path}:${java.library.path}"/>
<jvmarg value="-Djava.library.path=${tc.library.path}"/>
</java>
</target>
<target name="run-ssl-server" depends="compile-examples" description="Run the SSL Server example">
<echo message="Running Tomcat Native SSL Server example ..."/>
<java dir="${examples.dir}" classname="org.apache.tomcat.jni.SSLServer"
fork="yes" failonerror="${test.failonerror}">
<env key="PATH" path="${tc.library.path}:${java.library.path}"/>
<env key="Path" path="${tc.library.path}:${java.library.path}"/>
<classpath refid="examples.classpath"/>
<jvmarg value="-Djava.library.path=${tc.library.path}"/>
</java>
</target>
<target name="run-local-server" depends="compile-examples" description="Run the Local Server example">
<echo message="Running Tomcat Native Local Server example ..."/>
<java dir="${examples.dir}" classname="org.apache.tomcat.jni.LocalServer"
fork="yes" failonerror="${test.failonerror}">
<classpath refid="examples.classpath"/>
<env key="PATH" path="${tc.library.path}:${java.library.path}"/>
<env key="Path" path="${tc.library.path}:${java.library.path}"/>
<jvmarg value="-Djava.library.path=${tc.library.path}"/>
</java>
</target>
</project>