- 安装jdk,用jdk6即可,如果要编译JSR-356 (Java WebSocket 1.1)则需要jdk7.
- 安装ant,Ant 1.8.2或更新版本。
- 连到apache的svn上下载自己想要的版本,比如这里使用TOMCAT_7_0_73。
- Tomcat目录下新建build.properties文件,可以以build.properties.default文件作为模板修改,比如可以修改base.path=${user.home}/tomcat-build-libs,此路径用于构建过程中存放下载的文件。包含以下目录:
commons-daemon-1.0.15
commons-dbcp-1.4-src
commons-pool-1.5.7-src
ecj-4.4.2
tomcat7-deps
tomcat-native-1.2.10
- 如果使用了代理需要配置
proxy.host=proxy.domain
proxy.port=8080
proxy.use=on
- 运行ant构建
D:\workspace\tomcat-workspace\TOMCAT_7_0_73>ant
Buildfile: D:\workspace\tomcat-workspace\TOMCAT_7_0_73\build.xml
build-prepare:
[delete] Deleting directory D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\temp
[mkdir] Created dir: D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\temp
download-compile:
testexist:
[echo] Testing for C:\Users\wj/tomcat-build-libs/tomcat-native-1.2.10/tomcat-native.tar.gz
downloadfile-2:
proxyflags:
setproxy:
testexist:
[echo] Testing for C:\Users\wj/tomcat-build-libs/commons-daemon-1.0.15/commons-daemon-1.0.15.jar
downloadgz-2:
testexist:
[echo] Testing for C:\Users\wj/tomcat-build-libs/commons-daemon-1.0.15/commons-daemon-1.0.15-native-src.tar.gz
downloadfile-2:
proxyflags:
setproxy:
testexist:
[echo] Testing for C:\Users\wj/tomcat-build-libs/commons-pool-1.5.7-src/build.xml
downloadgz-2:
proxyflags:
setproxy:
testexist:
[echo] Testing for C:\Users\wj/tomcat-build-libs/commons-dbcp-1.4-src/build.xml
downloadgz-2:
build-prepare:
[delete] Deleting directory D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\temp
[mkdir] Created dir: D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\temp
build-manifests:
build-tomcat-dbcp:
testexist:
[echo] Testing for C:\Users\wj/tomcat-build-libs/ecj-4.4.2/ecj-4.4.2.jar
downloadfile-2:
compile-prepare:
download-validate:
validate:
compile-java6:
[copy] Copying 7 files to D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\classes\javax\servlet\resources
guess-java7:
check-java7:
compile-java7:
compile:
build-manifests:
package-java7:
package:
[jar] Building jar: D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\lib\annotations-api.jar
[jar] Building jar: D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\lib\servlet-api.jar
[jar] Building jar: D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\lib\jsp-api.jar
[jar] Building jar: D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\lib\el-api.jar
[jar] Building jar: D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\bin\bootstrap.jar
[jar] Building jar: D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\bin\tomcat-juli.jar
[jar] Building jar: D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\lib\catalina.jar
[jar] Building jar: D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\lib\catalina-tribes.jar
[jar] Building jar: D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\lib\catalina-ha.jar
[jar] Building jar: D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\lib\catalina-ant.jar
[jar] Building jar: D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\lib\tomcat-api.jar
[jar] Building jar: D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\lib\tomcat-util.jar
[jar] Building jar: D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\lib\tomcat-coyote.jar
[jar] Building jar: D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\lib\jasper.jar
[jar] Building jar: D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\lib\jasper-el.jar
build-docs:
[xslt] Transforming into D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\webapps\docs
[xslt] Transforming into D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\webapps\docs\appdev
[xslt] Transforming into D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\webapps\docs\funcspecs
[xslt] Transforming into D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\webapps\docs\config
[xslt] Transforming into D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\webapps\docs\architecture
[xslt] Transforming into D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\webapps\docs\tribes
compile-webapp-examples:
deploy:
examples-sources:
[txt2html] Converted 1 file to D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\webapps\examples\jsp\jsp2\simpletag
[txt2html] Converted 4 files to D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\webapps\examples\jsp\jsp2\simpletag
[txt2html] Converted 5 files to D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\webapps\examples\jsp\jsp2\simpletag
[txt2html] Converted 1 file to D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\webapps\examples\jsp\jsp2\jspattribute
[txt2html] Converted 4 files to D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\webapps\examples\jsp\jsp2\jspattribute
[txt2html] Converted 4 files to D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\webapps\examples\jsp\cal
[txt2html] Converted 1 file to D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\webapps\examples\jsp\jsptoserv
[txt2html] Converted 1 file to D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\webapps\examples\jsp\jsp2\el
[txt2html] Converted 2 files to D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\webapps\examples\jsp\jsp2\el
[txt2html] Converted 3 files to D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\webapps\examples\jsp\jsp2\el
[txt2html] Converted 1 file to D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\webapps\examples\jsp\jsp2\misc
[txt2html] Converted 4 files to D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\webapps\examples\jsp\jsp2\tagfiles
[txt2html] Converted 51 files to D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\webapps\examples
[copy] Copying 1 file to D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\lib
[echo] Building Tomcat JDBC pool libraries
prepare:
[mkdir] Created dir: D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\jdbc-pool\build
[mkdir] Created dir: D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\jdbc-pool\classes
[mkdir] Created dir: D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\jdbc-pool\testclasses
[copy] Copying 7 files to D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\jdbc-pool
download:
build-src:
[jar] Building jar: D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\jdbc-pool\tomcat-jdbc-src.jar
build:
[javac] Compiling 31 source files to D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\jdbc-pool\classes
[jar] Building jar: D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\jdbc-pool\tomcat-jdbc.jar
[copy] Copying 1 file to D:\workspace\tomcat-workspace\TOMCAT_7_0_73\output\build\lib
BUILD SUCCESSFUL
Total time: 30 seconds
可参考
http://tomcat.apache.org/tomcat-7.0-doc/building.html
点击订购作者《Tomcat内核设计剖析》