Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 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 | ====================================================
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 19 | Building The Apache Tomcat 7.0 Servlet/JSP Container
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 20 | ====================================================
|
| 21 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 22 | This subproject contains the source code for Tomcat 7.0, a container that
|
| 23 | implements the Servlet 3.0, JSP 2.2, EL 2.2 and WebSocket 1.1 specifications
|
| 24 | from the Java Community Process <http://www.jcp.org/>.
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 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 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 34 | (1) Download and Install a Java 6 and Java 7 Development Kit
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 35 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 36 | 1. If the JDKs are already installed, skip to (2).
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 37 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 38 | 2. Download a version 6 of the Java Development Kit (JDK) release (use the
|
| 39 | latest update available for your chosen version) from
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 40 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 41 | http://www.oracle.com/technetwork/java/javase/downloads/index.html
|
| 42 | or from another JDK vendor.
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 43 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 44 | Note regarding later versions of Java:
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 45 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 46 | As documented elsewhere, one of the components in Apache Tomcat includes
|
| 47 | a private copy of the Apache Commons DBCP library. The source code
|
| 48 | for this library is downloaded, processed by the build script
|
| 49 | (renaming the packages) and compiled.
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 50 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 51 | Due to changes in JDBC interfaces implemented by the library between
|
| 52 | versions of Java SE specification, the library has to target specific
|
| 53 | version of Java and can be compiled only with the JDK version
|
| 54 | implementing this version of specification. Therefore, the build Tomcat
|
| 55 | build process must be executed with a Java 6 JDK.
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 56 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 57 | See Apache Commons DBCP project web site for more details on
|
| 58 | available versions of the library and its requirements,
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 59 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 60 | http://commons.apache.org/dbcp/
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 61 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 62 | If you really want to use a later version of JDK to build Tomcat,
|
| 63 | several workarounds are possible. One of them is to skip building
|
| 64 | the component (tomcat-dbcp.jar).
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 65 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 66 | 3. Install the Java 6 JDK according to the instructions included with the
|
| 67 | release.
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 68 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 69 | 4. Set an environment variable JAVA_HOME to the pathname of the directory
|
| 70 | into which you installed the JDK release.
|
| 71 |
|
| 72 | 5. Download a version 7 of the Java Development Kit (JDK) release (use the
|
| 73 | latest update available for your chosen version) from
|
| 74 |
|
| 75 | http://www.oracle.com/technetwork/java/javase/downloads/index.html
|
| 76 | or from another JDK vendor.
|
| 77 |
|
| 78 | 6. Install the Java 7 JDK according to the instructions included with the
|
| 79 | release.
|
| 80 |
|
| 81 | * NOTE: The Java 7 JDK is only required if you wish to build Tomcat with
|
| 82 | JSR-356 (Java WebSocket 1.1) support.
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 83 |
|
| 84 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 85 | (2) Install Apache Ant version 1.8.2 or later on your computer
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 86 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 87 | 1. If Apache Ant version 1.8.2 or later is already installed on your computer, skip to (3).
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 88 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 89 | 2. Download a binary distribution of Ant from:
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 90 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 91 | http://ant.apache.org/bindownload.cgi
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 92 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 93 | 3. Unpack the binary distribution into a convenient location so that the
|
| 94 | Ant release resides in its own directory (conventionally named
|
| 95 | "apache-ant-[version]").
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 96 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 97 | For the purposes of the remainder of this document, the symbolic name
|
| 98 | "${ant.home}" is used to refer to the full pathname of the release
|
| 99 | directory.
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 100 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 101 | 4. Create an ANT_HOME environment variable to point the directory
|
| 102 | ${ant.home}.
|
| 103 |
|
| 104 | 5. Modify the PATH environment variable to include the directory
|
| 105 | ${ant.home}/bin in its list. This makes the "ant" command line script
|
| 106 | available, which will be used to actually perform the build.
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 107 |
|
| 108 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 109 | (3) Building Tomcat 7.0
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 110 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 111 | (3.1) Checkout or obtain the source code for Tomcat 7.0
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 112 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 113 | Checkout the source using SVN, selecting a tag for released version or
|
| 114 | trunk for the current development code, or download and unpack a source
|
| 115 | package.
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 116 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 117 | * Tomcat SVN repository URL:
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 118 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 119 | http://svn.apache.org/repos/asf/tomcat/tc7.0.x/trunk/
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 120 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 121 | * Source packages can be downloaded from:
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 122 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 123 | http://tomcat.apache.org/download-70.cgi
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 124 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 125 | The location where the source has been placed will be further referred as
|
| 126 | ${tomcat.source}.
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 127 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 128 | The Tomcat local build process does not modify line-endings. The svn repository
|
| 129 | is configured so that all files will be checked out with the line-ending
|
| 130 | appropriate for the current platform. When using a source package you should
|
| 131 | ensure that you use the source package that has the appropriate line-ending
|
| 132 | for your platform:
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 133 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 134 | zip -> CRLF
|
| 135 | tar.gz -> LF
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 136 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 137 | Note that the release build process does modify line-endings to ensure that
|
| 138 | each release package has the appropriate line-endings.
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 139 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 140 | (3.2) Building
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 141 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 142 | 1. The build is controlled by creating a ${tomcat.source}/build.properties
|
| 143 | file.
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 144 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 145 | It is recommended to always create the file, because of unfortunate
|
| 146 | default value of base.path property. You may start with the following
|
| 147 | content for the file:
|
| 148 |
|
| 149 | # ----- Default Base Path for Dependent Packages -----
|
| 150 | # Replace this path with the directory path where dependencies binaries
|
| 151 | # should be downloaded
|
| 152 | base.path=/home/me/some-place-to-download-to
|
| 153 |
|
| 154 | 2. Configure base.path property by adding it to the
|
| 155 | ${tomcat.source}/build.properties file.
|
| 156 |
|
| 157 | The base.path property specifies the place where Tomcat dependencies
|
| 158 | required by the build are downloaded. It is recommended to place this
|
| 159 | directory outside of the source tree, so that you do not waste your
|
| 160 | time re-downloading the libraries.
|
| 161 |
|
| 162 | * NOTE: The default value of the base.path property configures the build script
|
| 163 | to download the libraries required to build Tomcat to the
|
| 164 | ${user.home}/tomcat-build-libs directory.
|
| 165 |
|
| 166 | * NOTE: Users accessing the Internet through a proxy must use the properties
|
| 167 | file to indicate to Ant the proxy configuration.
|
| 168 |
|
| 169 | The following properties should be added to the ${tomcat.source}/build.properties
|
| 170 | file.
|
| 171 |
|
| 172 | proxy.use=on
|
| 173 | proxy.host=proxy.domain
|
| 174 | proxy.port=8080
|
| 175 | proxy.user=username
|
| 176 | proxy.password=password
|
| 177 |
|
| 178 | See Apache Ant documentation for the <setproxy> task for details.
|
| 179 |
|
| 180 | * NOTE: Users wishing to build Tomcat with JSR-356 (Java WebSocket 1.1) support
|
| 181 | must also set the java.7.home build property to the location of the Java 7 JDK
|
| 182 | installation.
|
| 183 |
|
| 184 | 3. Go to the sources directory and run Ant:
|
| 185 |
|
| 186 | cd ${tomcat.source}
|
| 187 | ant
|
| 188 |
|
| 189 | This will execute the "deploy" target in build.xml.
|
| 190 |
|
| 191 | Once the build has completed successfully, a usable Tomcat installation
|
| 192 | will have been produced in the ${tomcat.source}/output/build directory,
|
| 193 | and can be started and stopped with the usual scripts.
|
| 194 |
|
| 195 | Note that the build includes Tomcat documentation, which can be found
|
| 196 | in the output/build/webapps/docs directory.
|
| 197 |
|
| 198 | The path of the output directory can be controlled by specifying the
|
| 199 | "tomcat.output" property in the build.properties file.
|
| 200 |
|
| 201 | * NOTE: Do not run the build as the root user. Building and running Tomcat
|
| 202 | does not require root privileges.
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 203 |
|
| 204 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 205 | (4) Updating sources and rebuilding
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 206 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 207 | It is recommended that you regularly update the downloaded Tomcat 7.0
|
| 208 | sources using your SVN client.
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 209 |
|
| 210 | For a quick rebuild of only modified code you can use:
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 211 |
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 212 | cd ${tomcat.source}
|
| 213 | ant
|
| 214 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 215 |
|
| 216 | (5) Special builds
|
| 217 |
|
| 218 | There are several targets in Tomcat build files that are useful to be
|
| 219 | called separately. They build components that you may want to build
|
| 220 | quickly, or ones that are included in the full release and are not built
|
| 221 | during the default "deploy" build.
|
| 222 |
|
| 223 | (5.1) Building documentation
|
| 224 |
|
| 225 | The documentation web application is built during the default "deploy"
|
| 226 | build.
|
| 227 |
|
| 228 | It can be built quickly by using the following commands:
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 229 |
|
| 230 | cd ${tomcat.source}
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 231 | ant build-docs
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 232 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 233 | The output of this command will be found in the following directory:
|
| 234 |
|
| 235 | output/build/webapps/docs
|
| 236 |
|
| 237 |
|
| 238 | The API documentation (Javadoc) is built during a "release" build. It is
|
| 239 | easy to build it separately by using the following commands:
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 240 |
|
| 241 | cd ${tomcat.source}
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 242 | ant javadoc
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 243 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 244 | The output of this command will be found in the following directories:
|
| 245 |
|
| 246 | output/dist/webapps/docs/api
|
| 247 | output/dist/webapps/docs/elapi
|
| 248 | output/dist/webapps/docs/jspapi
|
| 249 | output/dist/webapps/docs/servletapi
|
| 250 |
|
| 251 |
|
| 252 | (5.2) Building the extras (commons-logging, webservices etc.)
|
| 253 |
|
| 254 | These components are documented on the "Additional Components"
|
| 255 | (extras.html) page of documentation. They are built during a "release"
|
| 256 | build.
|
| 257 |
|
| 258 | You can build them by using the following commands:
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 259 |
|
| 260 | cd ${tomcat.source}
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 261 | ant extras
|
| 262 |
|
| 263 | (5.3) Building the embedded packages
|
| 264 |
|
| 265 | These are built during a "release" build.
|
| 266 |
|
| 267 | You can build them by using the following commands:
|
| 268 |
|
| 269 | cd ${tomcat.source}
|
| 270 | ant embed
|
| 271 |
|
| 272 |
|
| 273 | (6) Building a full release (as provided via the ASF download pages)
|
| 274 |
|
| 275 | A full release includes the Windows installer which requires a Windows
|
| 276 | environment to be available to create it. If not building in a Windows
|
| 277 | environment, the build scripts assume that Wine is available. If this is not
|
| 278 | the case, the skip.installer property may be set to skip the creation of the
|
| 279 | Windows installer.
|
| 280 |
|
| 281 | 1. Configure GPG, if needed
|
| 282 |
|
| 283 | If the released artifacts have to be cryptographically signed with a
|
| 284 | PGP signature, like the official ASF releases are, the following
|
| 285 | property can be added to the build.properties file:
|
| 286 |
|
| 287 | # Location of GPG executable (used only for releases)
|
| 288 | gpg.exec=/path/to/gpg
|
| 289 |
|
| 290 | You do not need it if you do not plan to sign the release.
|
| 291 |
|
| 292 | If "gpg.exec" property does not point to an existing file, it will be
|
| 293 | ignored and this feature will be disabled.
|
| 294 |
|
| 295 | You will be prompted for the GPG passphrase when the release build
|
| 296 | starts, unless "gpg.passphrase" property is set.
|
| 297 |
|
| 298 | 2. Build the release:
|
| 299 |
|
| 300 | cd ${tomcat.source}
|
| 301 | ant release
|
| 302 |
|
| 303 |
|
| 304 | (7) Tests
|
| 305 |
|
| 306 | (7.1) Running Tomcat tests
|
| 307 |
|
| 308 | Tomcat includes a number of junit tests. The tests are not run when a
|
| 309 | release is built. There is separate command to run them.
|
| 310 |
|
| 311 | To run the testsuite use the following command:
|
| 312 |
|
| 313 | cd ${tomcat.source}
|
| 314 | ant test
|
| 315 |
|
| 316 | It is advisable to redirect output of the above command to a file for later
|
| 317 | inspection.
|
| 318 |
|
| 319 | The JUnit reports generated by the tests will be written to the following
|
| 320 | directory:
|
| 321 |
|
| 322 | output/build/logs
|
| 323 |
|
| 324 |
|
| 325 | By default the testsuite is run three times to test 3 different
|
| 326 | implementations of Tomcat connectors: BIO, NIO and APR. (If you are not
|
| 327 | familiar with Tomcat connectors, see config/http.html in documentation for
|
| 328 | details).
|
| 329 |
|
| 330 | The 3 runs are enabled and disabled individually by the following
|
| 331 | properties, which all are "true" by default:
|
| 332 |
|
| 333 | execute.test.bio=true
|
| 334 | execute.test.nio=true
|
| 335 | execute.test.apr=true
|
| 336 |
|
| 337 | The APR connector can be tested only if Tomcat-Native library binaries are
|
| 338 | found by the testsuite. The "test.apr.loc" property specifies the directory
|
| 339 | where the library binaries are located.
|
| 340 |
|
| 341 | By default the "test.apr.loc" property specifies the following location:
|
| 342 |
|
| 343 | output/build/bin/native/
|
| 344 |
|
| 345 | If you are on Windows and want to test the APR connector you can put the
|
| 346 | tcnative-1.dll file into ${tomcat.source}/bin/native/ and it will be copied
|
| 347 | into the above directory when the build runs.
|
| 348 |
|
| 349 | * NOTE: If you configured the build to use a Java 7 JDK (if the
|
| 350 | "java.7.home" property has been defined) the tests will be run with Java 7.
|
| 351 |
|
| 352 | The version of Java that was actually used to run the tests is reported by
|
| 353 | "org.apache.catalina.util.TestServerInfo" test class.
|
| 354 |
|
| 355 |
|
| 356 | (7.2) Running a single test
|
| 357 |
|
| 358 | It is possible to run a single JUnit test class by adding the "test.entry"
|
| 359 | property to the build.properties file. The property specifies the name of
|
| 360 | the test class.
|
| 361 |
|
| 362 | For example:
|
| 363 |
|
| 364 | test.entry=org.apache.catalina.util.TestServerInfo
|
| 365 |
|
| 366 | It is possible to further limit such run to a number of selected test
|
| 367 | methods by adding "test.entry.methods" property. The property specifies a
|
| 368 | comma-separated list of test case methods. (This feature requires
|
| 369 | Apache Ant 1.8.2 or later).
|
| 370 |
|
| 371 | For example:
|
| 372 |
|
| 373 | test.entry=org.apache.el.lang.TestELArithmetic
|
| 374 | test.entry.methods=testMultiply01,testMultiply02
|
| 375 |
|
| 376 |
|
| 377 | (7.3) Running a set of tests
|
| 378 |
|
| 379 | It is possible to run a set of JUnit test classes by adding the "test.name"
|
| 380 | property to the build.properties file. The property specifies an Ant
|
| 381 | includes pattern for the fileset of test class files to run.
|
| 382 |
|
| 383 | The default value is "**/Test*.java", so all test classes are being
|
| 384 | executed (with few exceptions - see build.xml for several exclude patterns).
|
| 385 |
|
| 386 | You can include multiple patterns by concatenating them with a comma (",")
|
| 387 | as the separator.
|
| 388 |
|
| 389 | For example:
|
| 390 |
|
| 391 | test.name=**/TestSsl.java,**/TestWebSocketFrameClientSSL.java
|
| 392 |
|
| 393 |
|
| 394 | (7.4) Other configuration options
|
| 395 |
|
| 396 | 1. It is possible to configure the directory where JUnit reports are
|
| 397 | written to. It is configured by "test.reports" property. The default
|
| 398 | value is
|
| 399 |
|
| 400 | output/build/logs
|
| 401 |
|
| 402 | 2. It is possible to enable generation of access log file when the tests
|
| 403 | are run. This is off by default and can be enabled by the following
|
| 404 | property:
|
| 405 |
|
| 406 | test.accesslog=true
|
| 407 |
|
| 408 | The "access_log.<date>" file will be written to the same directory as
|
| 409 | JUnit reports,
|
| 410 |
|
| 411 | output/build/logs
|
| 412 |
|
| 413 | 3. The testsuite respects logging configuration as configured by
|
| 414 | ${tomcat.source}/conf/logging.properties
|
| 415 |
|
| 416 | The log files will be written to the temporary directory used by the
|
| 417 | tests,
|
| 418 |
|
| 419 | output/test-tmp/logs
|
| 420 |
|
| 421 | 4. It is possible to configure formatter used by JUnit reports.
|
| 422 | Configuration properties are "junit.formatter.type",
|
| 423 | "junit.formatter.extension" and "junit.formatter.usefile".
|
| 424 |
|
| 425 | For example the following property disables generation of separate report
|
| 426 | files:
|
| 427 |
|
| 428 | junit.formatter.usefile=false
|
| 429 |
|
| 430 | 5. Optional support is provided for the Cobertura code coverage tool.
|
| 431 |
|
| 432 | * NOTE: Cobertura is licensed under GPL v2 with parts of it being under
|
| 433 | Apache License v1.1. See http://cobertura.sf.net for details. Using it
|
| 434 | during Tomcat build is optional and is off by default.
|
| 435 |
|
| 436 | Cobertura can be enabled using the following property:
|
| 437 |
|
| 438 | test.cobertura=true
|
| 439 |
|
| 440 | The report files by default are written to
|
| 441 |
|
| 442 | output/coverage
|
| 443 |
|
| 444 | 6. Some tests include checks that the access log valve entries are as expected.
|
| 445 | These checks include timings. On slower / loaded systems these checks will
|
| 446 | often fail. The checks may be relaxed by using the following property:
|
| 447 |
|
| 448 | test.relaxTiming=true
|
| 449 |
|
| 450 | 7. It is known that some platforms (e.g. OSX El Capitan) require IPv4 to
|
| 451 | be the default for the multicast tests to work. This is configured by
|
| 452 | the following property:
|
| 453 |
|
| 454 | java.net.preferIPv4Stack=true
|
| 455 |
|
| 456 | 8. It is possible to control whether the output of the tests is displayed
|
| 457 | on the console or not. By default it is displayed and can be disabled
|
| 458 | by the following property:
|
| 459 |
|
| 460 | test.verbose=true
|
| 461 |
|
| 462 | (8) Source code checks
|
| 463 |
|
| 464 | (8.1) Checkstyle
|
| 465 |
|
| 466 | * NOTE: Checkstyle is licensed under LGPL. Using Checkstyle during Tomcat
|
| 467 | build is optional and is off by default.
|
| 468 |
|
| 469 | Tomcat comes with a Checkstyle configuration that tests its source code
|
| 470 | for certain conventions, like presence of the license header.
|
| 471 |
|
| 472 | To enable Checkstyle, add the following property to build.properties file:
|
| 473 |
|
| 474 | execute.validate=true
|
| 475 |
|
| 476 | Once Checkstyle is enabled, the check will be performed automatically
|
| 477 | during the build. The check is run before compilation of the source code.
|
| 478 |
|
| 479 | To speed-up repeated runs of this check, a cache is configured. The cache
|
| 480 | is located in the following directory:
|
| 481 |
|
| 482 | output/res/checkstyle
|
| 483 |
|
| 484 | It is possible to run the check separately by invoking the "validate"
|
| 485 | target. The command is:
|
| 486 |
|
| 487 | cd ${tomcat.source}
|
| 488 | ant -Dexecute.validate=true validate
|
| 489 |
|
| 490 |
|
| 491 | (8.2) End-of-line conventions check
|
| 492 |
|
| 493 | You usually would not need to run this check. You can skip this section.
|
| 494 |
|
| 495 | Apache Tomcat project has convention that all of its textual source files,
|
| 496 | stored in Subversion repository, are marked with Subversion property
|
| 497 | "svn:eol-style" with value of "native". This convention makes the editing
|
| 498 | of source code on different platforms easier.
|
| 499 |
|
| 500 | This test is used by developers to check that the source code adheres to
|
| 501 | this convention. It verifies that the ends of lines in textual files are
|
| 502 | appropriate for the operating system where it is run. The idea is to run
|
| 503 | this check regularly on two different platforms and notify developers when
|
| 504 | an inconsistency is detected.
|
| 505 |
|
| 506 | The command to run this test is:
|
| 507 |
|
| 508 | cd ${tomcat.source}
|
| 509 | ant validate-eoln
|