Subversion Repositories Integrator Subversion

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
771 blopes 1
================================================================================
2
  Licensed to the Apache Software Foundation (ASF) under one or more
3
  contributor license agreements.  See the NOTICE file distributed with
4
  this work for additional information regarding copyright ownership.
5
  The ASF licenses this file to You under the Apache License, Version 2.0
6
  (the "License"); you may not use this file except in compliance with
7
  the License.  You may obtain a copy of the License at
8
 
9
      http://www.apache.org/licenses/LICENSE-2.0
10
 
11
  Unless required by applicable law or agreed to in writing, software
12
  distributed under the License is distributed on an "AS IS" BASIS,
13
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
  See the License for the specific language governing permissions and
15
  limitations under the License.
16
================================================================================
17
 
18
            ====================================================
19
            Building The Apache Tomcat 9.0 Servlet/JSP Container
20
            ====================================================
21
 
22
This project contains the source code for Tomcat 9.0, a container that
23
implements the Servlet 4.0, JSP 2.3, EL 3.0, WebSocket 1.1 and JASPIC 1.1
24
specifications from the Java Community Process <https://www.jcp.org/>.
25
 
26
Note: If you just need to run Apache Tomcat, it is not necessary to build
27
it. You may simply download a binary distribution. It is cross-platform.
28
Read RUNNING.txt for the instruction on how to run it.
29
 
30
In order to build a binary distribution version of Apache Tomcat from a
31
source distribution, do the following:
32
 
33
 
34
(1) Download and Install a Java Development Kit
35
 
36
 1. If the JDK is already installed, skip to (2).
37
 
38
 2. Download a version 17 or later of Java Development Kit (JDK) release (use
39
    the latest update available for your chosen version) from one of:
40
 
41
        http://www.oracle.com/technetwork/java/javase/downloads/index.html
42
        http://openjdk.java.net/install/index.html
43
        or another JDK vendor.
44
 
45
    Note regarding later versions of Java:
46
 
47
      As documented elsewhere, one of components in Apache Tomcat includes
48
      a private copy of the Apache Commons DBCP 2 library.
49
 
50
      The JDBC interfaces implemented by DBCP frequently change in non-backwards
51
      compatible ways between versions of the Java SE specification. Therefore,
52
      it is likely that DBCP 2 will only compile with the specific version of Java
53
      listed above and that compilation will fail if a later version of Java is
54
      used.
55
 
56
      See Apache Commons DBCP 2 project web site for more details on
57
      available versions of the library and its requirements,
58
 
59
        https://commons.apache.org/dbcp/
60
 
61
 3. Install the JDK according to the instructions included with the release.
62
 
63
 4. Set an environment variable JAVA_HOME to the pathname of the directory
64
    into which you installed the JDK release.
65
 
66
 
67
(2) Install Apache Ant version 1.10.2 or later on your computer.
68
 
69
 1. If Apache Ant version 1.10.2 or later is already installed on your
70
    computer, skip to (3).
71
 
72
 2. Download a binary distribution of Ant from:
73
 
74
        https://ant.apache.org/bindownload.cgi
75
 
76
 3. Unpack the binary distribution into a convenient location so that the
77
    Ant release resides in its own directory (conventionally named
78
    "apache-ant-[version]").
79
 
80
    For the purposes of the remainder of this document, the symbolic name
81
    "${ant.home}" is used to refer to the full pathname of the release
82
    directory.
83
 
84
 4. Create an ANT_HOME environment variable to point the directory
85
    ${ant.home}.
86
 
87
 5. Modify the PATH environment variable to include the directory
88
    ${ant.home}/bin in its list.  This makes the "ant" command line script
89
    available, which will be used to actually perform the build.
90
 
91
 
92
(3) Building Tomcat 9.0
93
 
94
(3.1) Checkout or obtain the source code for Tomcat 9.0
95
 
96
Clone the source using git, then checkout a specific major branch or
97
main for the latest code development, or download and unpack a source
98
package.
99
 
100
 *  Tomcat GitHub repository URL:
101
 
102
        https://github.com/apache/tomcat
103
 
104
 *  Source packages can be downloaded from:
105
 
106
        https://tomcat.apache.org/download-90.cgi
107
 
108
The location where the source has been placed will be further referred as
109
${tomcat.source}.
110
 
111
The Tomcat local build process does not modify line-endings. The svn repository
112
is configured so that all files will be checked out with the line-ending
113
appropriate for the current platform. When using a source package you should
114
ensure that you use the source package that has the appropriate line-ending
115
for your platform:
116
 
117
  zip    -> CRLF
118
  tar.gz -> LF
119
 
120
Note that the release build process does modify line-endings to ensure that
121
each release package has the appropriate line-endings.
122
 
123
(3.2) Building
124
 
125
 1. The build is controlled by creating a ${tomcat.source}/build.properties
126
    file.
127
 
128
    It is recommended to always create the file, because of unfortunate
129
    default value of base.path property. You may start with the following
130
    content for the file:
131
 
132
        # ----- Default Base Path for Dependent Packages -----
133
        # Replace this path with the directory path where dependencies binaries
134
        # should be downloaded
135
        base.path=/home/me/some-place-to-download-to
136
 
137
 2. Configure base.path property by adding it to the
138
    ${tomcat.source}/build.properties file.
139
 
140
    The base.path property specifies the place where Tomcat dependencies
141
    required by the build are downloaded. It is recommended to place this
142
    directory outside of the source tree, so that you do not waste your
143
    time re-downloading the libraries.
144
 
145
* NOTE: The default value of the base.path property configures the build script
146
  to download the libraries required to build Tomcat to the
147
  ${user.home}/tomcat-build-libs directory.
148
 
149
* NOTE: Users accessing the Internet through a proxy must use the properties
150
  file to indicate to Ant the proxy configuration.
151
 
152
  The following properties should be added to the ${tomcat.source}/build.properties
153
  file.
154
 
155
        proxy.use=true
156
        proxy.host=proxy.domain
157
        proxy.port=8080
158
        proxy.user=username
159
        proxy.password=password
160
 
161
  See Apache Ant documentation for the <setproxy> task for details.
162
 
163
 3. Go to the sources directory and run Ant:
164
 
165
        cd ${tomcat.source}
166
        ant
167
 
168
    This will execute the "deploy" target in build.xml.
169
 
170
    Once the build has completed successfully, a usable Tomcat installation
171
    will have been produced in the ${tomcat.source}/output/build directory,
172
    and can be started and stopped with the usual scripts.
173
 
174
    Note that the build includes Tomcat documentation, which can be found
175
    in the output/build/webapps/docs directory.
176
 
177
    The path of the output directory can be controlled by specifying the
178
    "tomcat.output" property in the build.properties file.
179
 
180
* NOTE: Do not run the build as the root user. Building and running Tomcat
181
  does not require root privileges.
182
 
183
 
184
(4) Updating sources and rebuilding
185
 
186
It is recommended that you regularly update the downloaded Tomcat 9.0
187
sources using your git client.
188
 
189
For a quick rebuild of only modified code you can use:
190
 
191
    cd ${tomcat.source}
192
    ant
193
 
194
 
195
(5) Special builds
196
 
197
There are several targets in Tomcat build files that are useful to be
198
called separately. They build components that you may want to build
199
quickly, or ones that are included in the full release and are not built
200
during the default "deploy" build.
201
 
202
(5.1) Building documentation
203
 
204
The documentation web application is built during the default "deploy"
205
build.
206
 
207
It can be built quickly by using the following commands:
208
 
209
    cd ${tomcat.source}
210
    ant build-docs
211
 
212
The output of this command will be found in the following directory:
213
 
214
    output/build/webapps/docs
215
 
216
 
217
The API documentation (Javadoc) is built during a "release" build. It is
218
easy to build it separately by using the following commands:
219
 
220
    cd ${tomcat.source}
221
    ant javadoc
222
 
223
The output of this command will be found in the following directories:
224
 
225
    output/dist/webapps/docs/api
226
    output/dist/webapps/docs/elapi
227
    output/dist/webapps/docs/jspapi
228
    output/dist/webapps/docs/servletapi
229
 
230
 
231
(5.2) Building the extras (commons-logging, webservices etc.)
232
 
233
These components are documented on the "Additional Components"
234
(extras.html) page of documentation. They are built during a "release"
235
build.
236
 
237
You can build them by using the following commands:
238
 
239
    cd ${tomcat.source}
240
    ant extras
241
 
242
(5.3) Building the embedded packages
243
 
244
These are built during a "release" build.
245
 
246
You can build them by using the following commands:
247
 
248
    cd ${tomcat.source}
249
    ant embed
250
 
251
(5.4) Building the Windows installer
252
 
253
The Windows installer uses the NSIS installer framework.
254
It can be build on Windows, on any other platform which provides
255
the Wine Windows emulator or the NSIS binary "makensis".
256
 
257
Linux and MacOS are platforms, on which you can install Wine or
258
"makensis".
259
 
260
Selecting between Wine and makensis on non-Windows platforms can
261
be done by setting the ant property "nsis.tool" to either "wine"
262
or "makensis" in build.properties.
263
 
264
If you want to sign the installer, you will need to set some
265
properties with names prefixed with "codesigning" in your build.properties.
266
For details see the targets "jsign-installer" and "jsign-uninstaller"
267
in build.xml and the default property values in build.properties.default.
268
 
269
 
270
(6) Building a full release (as provided via the ASF download pages)
271
 
272
 1. Remark on building the Windows installer
273
 
274
    A full release includes the Windows installer which requires a Windows
275
    environment, an installed Wine emulator or an installed native
276
    "makensis" binary from the NSIS project. Creating a reproducible
277
    installer using the "makensis" option needs a special build of "makensis".
278
    For details see below.
279
 
280
    Provided that Wine or "makensis" is available on non-Windows platforms,
281
    a full release build may be made on Windows, Linux or MacOS.
282
 
283
    If you do not want to build the Windows installer, the skip.installer
284
    property may be set to skip the creation of the Windows installer.
285
 
286
 2. Configure GPG, if needed
287
 
288
    If the released artifacts have to be cryptographically signed with a
289
    PGP signature, like the official ASF releases are, the following
290
    property can be added to the build.properties file:
291
 
292
        # Location of GPG executable (used only for releases)
293
        gpg.exec=/path/to/gpg
294
 
295
    You do not need it if you do not plan to sign the release.
296
 
297
    If "gpg.exec" property does not point to an existing file, it will be
298
    ignored and this feature will be deactivated.
299
 
300
    You will be prompted for the GPG passphrase when the release build
301
    starts, unless "gpg.passphrase" property is set.
302
 
303
 3. If building the Windows installer on Windows
304
 
305
    If running the build in a UAC enabled environment, building the Windows
306
    installer requires elevated privileges. The simplest way to do this is to
307
    open the command prompt used for the build with the "Run as administrator"
308
    option.
309
 
310
 4. Configure the code signing service
311
 
312
    ASF committers performing official releases will need to configure the code
313
    signing service so that the Windows installer is signed during the build
314
    process. The following properties need to be added to the build.properties
315
    file:
316
 
317
        # Location of GPG executable (used only for releases)
318
        gpg.exec=/path/to/gpg
319
        # Code signing of Windows installer
320
        do.codesigning=true
321
        codesigning.storepass=request-via-pmc
322
        codesigning.keypass=request-via-pmc
323
 
324
    Release managers will be provided with the necessary credentials by the PMC.
325
 
326
    If you want to verify the installer from a release by rebuilding it,
327
    you can use the detached signatures provided in the official releases.
328
    In this case you have to use the sources from the source release
329
    archive, which contains these signatures. You also have to build
330
    on Windows, use Wine, or use a special build of makensis to create
331
    a reproducible installer, that fits the signature files.
332
 
333
 5. Using a special "makensis" build on non-Windows (optional)
334
 
335
    If you want to build a reproducible installer on non-Windows
336
    by using "makensis" instead of "Wine", you need to build
337
    "makensis" from a source download yourself. To build "makensis",
338
    you need python, scons and a C compiler. You can build "makensis"
339
    via an Ant target:
340
 
341
    ant local-makensis
342
 
343
    or you can build it manually using the following recipe.
344
 
345
    First detect the needed version by looking for nsis.version
346
    in build.properties.default.
347
 
348
    Download and extract NSIS for Windows by running "ant download-dist". Note
349
    the NSIS installation path from the output or by checking "nsis.bin.home" in
350
    build.properties.default. For example by default:
351
    nsis.bin.home=${base.path}/nsis-${nsis.version}
352
 
353
    The corresponding sources will be downloaded to "nsis.src.home" in
354
    build.properties.default. For example by default:
355
    nsis.src.home=${base.path}/nsis-${nsis.version}-src
356
 
357
    Install the scons Python software construction tool.
358
 
359
    Run the following command in the extracted NSIS source directory:
360
 
361
        scons UNICODE=yes PREFIX=${base.path}/nsis-${nsis.version}/Bin SKIPPLUGINS=all SKIPUTILS=all SKIPMISC=all NSIS_CONFIG_CONST_DATA_PATH=no VERSION=${nsis.version} install-compiler
362
 
363
    You need to specify the correct value in VERSION (this ends up in the installer binary
364
    so it needs to match). The PREFIX is not important, but you need to make sure
365
    that the created binary "makensis" gets finally put into the "Bin" directory of
366
    the NSIS binary distribution that "ant download-dist" installed. When using
367
    "NSIS_CONFIG_CONST_DATA_PATH=no" the binary is independent of the value of "PREFIX".
368
 
369
    In addition set the ant property "nsis.tool" to "makensis" in
370
    build.properties.
371
 
372
 6. Build the release:
373
 
374
    Apache Tomcat releases are fully reproducible.
375
 
376
    Release managers producing release builds must follow the following
377
    procedure:
378
 
379
    cd ${tomcat.source}
380
    ant pre-release
381
    ant release
382
    git commit -a -m "Tag <version-number>"
383
    git tag <vesion-number>
384
    git push origin <version-number>
385
    ant release
386
    git reset --hard HEAD~1
387
 
388
    The output from either 'ant release' call may be uploaded as the official
389
    release since they will be identical. It is recommended that the output from
390
    the second call is used.
391
 
392
    Anyone wishing to reproduce an official build must do so from an official
393
    source release. The build tool chain defined in build.properties.release
394
    must be used to reproduce an official build. Once unpacked to
395
    ${tomcat.source}, the following steps must be followed
396
 
397
    cd ${tomcat.source}
398
    ant release
399
 
400
    Following the same steps without using the defined build tool chain will
401
    create a release that is functionally the same as an official release but
402
    not bit for bit identical.
403
 
404
 
405
(7) Tests
406
 
407
(7.1) Running Tomcat tests
408
 
409
Tomcat includes a number of junit tests. The tests are not run when a
410
release is built. There is separate command to run them.
411
 
412
To run the testsuite use the following command:
413
 
414
    cd ${tomcat.source}
415
    ant test
416
 
417
It is advisable to redirect output of the above command to a file for later
418
inspection.
419
 
420
The JUnit reports generated by the tests will be written to the following
421
directory:
422
 
423
    output/build/logs
424
 
425
By default the testsuite is run three times to test 3 different
426
implementations of Tomcat connectors: NIO, NIO2 and APR. (If you are not
427
familiar with Tomcat connectors, see config/http.html in documentation for
428
details).
429
 
430
The 3 runs are activated and deactivated individually by the following
431
properties, which all are "true" by default:
432
 
433
    execute.test.nio=true
434
    execute.test.nio2=true
435
    execute.test.apr=true
436
 
437
The APR connector can be tested only if Tomcat-Native library binaries are
438
found by the testsuite. The "test.apr.loc" property specifies the directory
439
where the library binaries are located.
440
 
441
By default the "test.apr.loc" property specifies the following location:
442
 
443
    output/build/bin/
444
 
445
If you are on Windows and want to test the APR connector you can put the
446
tcnative-1.dll file into ${tomcat.source}/bin/ and it will be copied
447
into the above directory when the build runs.
448
 
449
The unit tests include tests of the clustering functionality which require
450
multicast to be enabled. There is a simple application provided in the Tomcat
451
test source (org.apache.catalina.tribes.TesterMulticast) that can be used to
452
check if a machine supports multicast. Notes on enabling multicast for different
453
operating systems are provided in the Javadoc for that class.
454
 
455
 
456
(7.2) Running a single test
457
 
458
It is possible to run a single JUnit test class by adding the "test.entry"
459
property to the build.properties file. The property specifies the name of
460
the test class.
461
 
462
For example:
463
 
464
    test.entry=org.apache.catalina.util.TestServerInfo
465
 
466
It is possible to further limit such run to a number of selected test
467
methods by adding "test.entry.methods" property. The property specifies a
468
comma-separated list of test case methods.
469
 
470
For example:
471
 
472
    test.entry=org.apache.el.lang.TestELArithmetic
473
    test.entry.methods=testMultiply01,testMultiply02
474
 
475
 
476
(7.3) Running a set of tests
477
 
478
It is possible to run a set of JUnit test classes by adding the "test.name"
479
property to the build.properties file. The property specifies an Ant
480
includes pattern for the fileset of test class files to run.
481
 
482
The default value is "**/Test*.java", so all test classes are being
483
executed (with few exceptions - see build.xml for several exclude patterns).
484
 
485
You can include multiple patterns by concatenating them with a comma (",")
486
as the separator.
487
 
488
For example:
489
 
490
    test.name=**/TestSsl.java,**/TestWebSocketFrameClientSSL.java
491
 
492
You can exclude specific JUnit test classes by adding the "test.exclude"
493
property to the build.properties file. The property specifies an Ant
494
excludes pattern for the fileset of test class files to exclude form the run.
495
The default value is empty, so no classes are excluded. The syntax is the same
496
as for the property "test.name".
497
 
498
 
499
(7.4) Other configuration options
500
 
501
 1. It is possible to configure the directory where JUnit reports are
502
 written to. It is configured by "test.reports" property. The default
503
 value is
504
 
505
        output/build/logs
506
 
507
 2. It is possible to enable generation of access log file when the tests
508
 are run. This is off by default and can be enabled by the following
509
 property:
510
 
511
        test.accesslog=true
512
 
513
 The "access_log.<date>" file will be written to the same directory as
514
 JUnit reports,
515
 
516
        output/build/logs
517
 
518
 3. The testsuite respects logging configuration as configured by
519
 ${tomcat.source}/conf/logging.properties
520
 
521
 The log files will be written to the temporary directory used by the
522
 tests,
523
 
524
        output/test-tmp/logs
525
 
526
 4. It is possible to configure formatter used by JUnit reports.
527
 Configuration properties are "junit.formatter.type",
528
 "junit.formatter.extension" and "junit.formatter.usefile".
529
 
530
 For example the following property deactivates generation of separate report
531
 files:
532
 
533
        junit.formatter.usefile=false
534
 
535
 5. It is possible to speed up testing by letting JUnit to run several
536
 tests in parallel.
537
 
538
 This is configured by setting "test.threads" property. The recommended
539
 value is one thread per core.
540
 
541
 6. Optional support is provided for the Cobertura code coverage tool.
542
 
543
NOTE: Cobertura is licensed under GPL v2 with parts of it being under
544
      Apache License v1.1. See https://cobertura.github.io/cobertura/ for details.
545
      Using it during Tomcat build is optional and is off by default.
546
 
547
 Cobertura can be enabled using the following properties:
548
 
549
        test.cobertura=true
550
        test.threads=1
551
 
552
 Using Cobertura currently requires setting test.threads configuration
553
 property to the value of 1. Setting that property to a different value
554
 will deactivate code coverage.
555
 
556
 The report files by default are written to
557
 
558
        output/coverage
559
 
560
 7. The performance tests are written to run on reasonably powerful machines
561
    (such as a developer may use day to day) assuming no other resource hungry
562
    processes are running.
563
 
564
    Performance tests may be an absolute test (how long to complete a number
565
    of iterations of an operation or set of operations) or may be a relative
566
    test (how long two or more different approaches take to generate the same
567
    result). The absolute tests may be destructive in that they run until the
568
    system runs out of resources.
569
 
570
    Where there is no benefit in running an absolute performance test as part
571
    of a standard test run, the test will be excluded by naming it
572
    Tester*Performance.java.
573
 
574
    The relative tests are included as part of a standard test run however,
575
    where the assumptions made about host capabilities are  not true (e.g. on
576
    CI systems running in virtual machine) the tests may be deactivated by
577
    using the following property:
578
 
579
        test.excludePerformance=true
580
 
581
 8. Some tests are require large heaps (e.g. 8GB). The CI systems used by the
582
    project either cannot support heaps of this size or do not support them by
583
    default. These tests are therefore disabled by default and may be enabled by
584
    using the following property:
585
 
586
        test.includeLargeHeap=true
587
 
588
 9. Some tests include checks that the access log valve entries are as expected.
589
    These checks include timings. On slower / loaded systems these checks will
590
    often fail. The checks may be relaxed by using the following property:
591
 
592
        test.relaxTiming=true
593
 
594
 10. It is known that some platforms (e.g. OSX El Capitan) require IPv4 to
595
     be the default for the multicast tests to work. This is configured by
596
     the following property:
597
 
598
        java.net.preferIPv4Stack=true
599
 
600
 11. By default the output of unit tests is sent to the console and can be
601
     quite verbose. The output can be deactivated by setting the property:
602
 
603
        test.verbose=false
604
 
605
(8) Source code checks
606
 
607
(8.1) Checkstyle
608
 
609
NOTE: Checkstyle is licensed under LGPL. Using Checkstyle during Tomcat
610
      build is optional and is off by default.
611
 
612
      See http://checkstyle.sourceforge.net/ for more information.
613
 
614
Tomcat comes with a Checkstyle configuration that tests its source code
615
for certain conventions, like presence of the license header.
616
 
617
To enable Checkstyle, add the following property to build.properties file:
618
 
619
    execute.validate=true
620
 
621
Once Checkstyle is enabled, the check will be performed automatically
622
during the build. The check is run before compilation of the source code.
623
 
624
To speed-up repeated runs of this check, a cache is configured. The cache
625
is located in the following directory:
626
 
627
    output/res/checkstyle
628
 
629
It is possible to run the check separately by calling the "validate"
630
target. The command is:
631
 
632
    cd ${tomcat.source}
633
    ant -Dexecute.validate=true validate
634
 
635
 
636
(8.2) SpotBugs
637
 
638
NOTE: SpotBugs is licensed under LGPL. Using SpotBugs during Tomcat build is
639
      optional and is off by default.
640
 
641
      See https://spotbugs.github.io/ for more information.
642
 
643
To enable SpotBugs, add the following property to build.properties file:
644
 
645
    execute.spotbugs=true
646
 
647
To compile Tomcat classes and generate a SpotBugs report, call the
648
"spotbugs" target. For example:
649
 
650
    cd ${tomcat.source}
651
    ant -Dexecute.spotbugs=true spotbugs
652
 
653
The report file by default is written to
654
 
655
    output/spotbugs
656
 
657
 
658
(8.3) End-of-line conventions check
659
 
660
You usually would not need to run this check. You can skip this section.
661
 
662
Apache Tomcat project has convention that all of its textual source files,
663
stored in the Git repository, use Unix style LF line endings.
664
 
665
This test is used by developers to check that the source code adheres to
666
this convention. It verifies that the ends of lines in textual files are
667
appropriate. The idea is to run this check regularly and notify developers
668
when an inconsistency is detected.
669
 
670
The command to run this test is:
671
 
672
    cd ${tomcat.source}
673
    ant validate-eoln