Tomcat6源代码分析-构建tomcat

 

1,Tomcat6 源文件目录树结构

目录结构如下图:

clip_image002

目录:

/bin 存放脚本文件,包括启动tomcat以及关闭tomcat等功能的bat,sh脚本。

/conf 存放tomcat的xml配置文件和properties配置文件。

/java java源代码放置到这个目录。

/native tomcat的native-connector工程放置的目录,是一个vc60工程。

/res ini文件及其它的一些静态资源文件可以放在res目录,以及生成可执行文件的nsis脚本。

/test 放置测试文件,项目

/webapps 放置tomcat的web工程文件

文件:

/build.properties.default 构建工程的属性文件

/build.xml ant 构建文件

/dist.xml 生成目标的构建文件

/extras.xml 扩展的构建文件

/其他 其他为说明文件

2,如何构建Tomcat6

(0)下载安装jdk1.5或者以上版本,设置JAVA_HOME环境变量指向JDK的安装目录。如果已经安装jdk,跳转到步骤1。

(1)安装apache ant 1.6.x。如果已经安装,请跳转到步骤2.下载apache

http://ant.apache.org/bindownload.cgi 。安装。

*创建ANT_HOME 环境变量,指向ant的安装目录 ${ant.home}.

* 在系统PATH环境变量中添加${ant.home}/bin .

(2)构建 Tomcat 6.0

(2.1)获取 Tomcat 6.0的源代码

* Tomcat SVN repository URL:

http://svn.apache.org/repos/asf/tomcat/tc6.0.x/

* Download a source package from:

http://tomcat.apache.org/download-60.cgi

* Checkout the source using SVN, selecting the desired version or

branch (current development source is at

http://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk/), or

unpack the source package. The location where the source has been

placed will be referred as ${tomcat.source}.

(2.2) 构建

* Go to that directory, and do:

cd ${tomcat.source}

ant download

ant

* NOTE: Users accessing the Internet through a proxy must use a properties

file to indicate to Ant the proxy configuration. Read below.

* WARNING: Running this command will download binaries to the /usr/share/java

directory. Make sure this is appropriate to do on your computer. On Windows,

this usually corresponds to the "C:/usr/share/java" directory, unless Cygwin

is used. Read below to customize the directory used to download the binaries.

* The build can be controlled by creating a ${tomcat.source}/build.properties

file, and adding the following content to it:

# ----- Proxy setup -----

# Uncomment if using a proxy server

#proxy.host=proxy.domain

#proxy.port=8080

#proxy.use=on

# ----- Default Base Path for Dependent Packages -----

# Replace this path with the directory path where dependencies binaries

# should be downloaded

base.path=/usr/share/java

(3) Updating sources

It is recommended that you regularly update the downloaded Tomcat 6 sources

using your SVN client.

(4) Rebuilds

For a quick rebuild of only modified code you can use:

cd ${tomcat.source}

ant

(5) Building the servlet and jsp API documentation

The documentation can be easly built:

cd ${tomcat.source}

ant -f dist.xml dist-javadoc

(6) Building the extras (commons-logging, webservices etc.).

cd ${tomcat.source}

ant -f extras.xml

(7) Building a release running tests:

cd ${tomcat.source}

ant -f dist.xml release

3,build.xml解析

Build.xml是一个标准的ant的构建文件,通过此文件,可以构建tomcat工程。大纲结构如下:

clip_image004

分析:

1,Tomcat工程的默认目标是deploy。

2,在工程的开头,首先指定构建文件的属性文件和属性。属性文件为build.properties.

3, download目标作用为下载tomcat编译依赖的库文件等。它依赖于如下几个目标。

clip_image006

setproxy,proxyflags目标任务是设置网络代理,testexit,downloadgz,downloadzip, downloadfile这几个目标共同完成下载依赖文件的任务。Build-tomcat-dbcp,build-jasper-jdt作用是编译下载的依赖文件。

4,deploy目标作用生成/output/classes,和/output/build目录,编译java源代码生成class文件存放到classes目录,部署tomcat在build目录。

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值