设为首页 收藏本站
查看: 618|回复: 0

[经验分享] Tomcat6源代码分析-构建tomcat

[复制链接]

尚未签到

发表于 2017-1-26 06:42:26 | 显示全部楼层 |阅读模式

  1,Tomcat6 源文件目录树结构
  目录结构如下图:
DSC0000.jpg

  目录:
  /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工程。大纲结构如下:
DSC0001.jpg

  分析:
  1,Tomcat工程的默认目标是deploy。
  2,在工程的开头,首先指定构建文件的属性文件和属性。属性文件为build.properties.
  3, download目标作用为下载tomcat编译依赖的库文件等。它依赖于如下几个目标。
DSC0002.jpg

  setproxy,proxyflags目标任务是设置网络代理,testexit,downloadgz,downloadzip, downloadfile这几个目标共同完成下载依赖文件的任务。Build-tomcat-dbcp,build-jasper-jdt作用是编译下载的依赖文件。
  4,deploy目标作用生成/output/classes,和/output/build目录,编译java源代码生成class文件存放到classes目录,部署tomcat在build目录。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-333417-1-1.html 上篇帖子: tomcat连接池配置再学习...... 下篇帖子: tomcat中的manager页的403错误
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表