Table of Contents
Introduction

Building Apache Tomcat from source is very easy, and is the first step to contributing to Tomcat. The following is a step by step guide.

Download a Java Development Kit (JDK) version 6

Building Apache Tomcat requires a JDK (version 6) to be installed. You can download one from
http://www.oracle.com/technetwork/java/javase/downloads/index.html
or from another JDK vendor.

IMPORTANT: Set an environment variable JAVA_HOME to the pathname of the directory into which you installed the JDK release.

Install Apache Ant 1.8.1 or later

Download a binary distribution of Ant 1.8.1 or later from here.

Unpack the binary distribution into a convenient location so that the Ant release resides in its own directory (conventionally named apache-ant-1.8.x). For the remainder of this guide, the symbolic name ${ant.home} is used to refer to the full pathname of the Ant installation directory directory.

IMPORTANT: Create an ANT_HOME environment variable to point the directory ${ant.home}, and modify the PATH environment variable to include directory ${ant.home}/bin in its list. This makes the ant command line script available, which will be used to actually perform the build.

Checkout or obtain the source code for Tomcat 7.0

Tomcat 7.0 SVN repository URL: http://svn.apache.org/repos/asf/tomcat/tc7.0.x/trunk/

Tomcat source packages: http://tomcat.apache.org/download-70.cgi.

Checkout the source using SVN, selecting a tag for released version or trunk for the current development code, or download and unpack a source package. For the remainder of this guide, the symbolic name ${tomcat.source} is used to refer to the location where the source has been placed.

Building Tomcat

Use the following commands to build Tomcat:

cd ${tomcat.source}
ant

WARNING: Running this command will download libraries required to build Tomcat to the /usr/share/java directory by default. On a typical Linux or MacOX system, an ordinary user will not have access to write to this directory, and, even if you do, it is likely not appropriate for you to write there. On Windows this usually corresponds to theC:\usr\share\java directory, unless Cygwin is used. Read below to learn how to customize the directory used to download the binaries.

NOTE: Users accessing the Internet through a proxy must use a properties file to indicate to Ant the proxy configuration. Read below for details.

The build can be controlled by creating a ${tomcat.source}/build.properties file and adding the following content to it:

  1. # ----- Proxy setup -----
  2. # Uncomment if using a proxy server.
  3. #proxy.host=proxy.domain
  4. #proxy.port=8080
  5. #proxy.use=on
  6. # ----- Default Base Path for Dependent Packages -----
  7. # Replace this path with the directory path where
  8. # dependencies binaries should be downloaded.
  9. base.path=/home/me/some-place-to-download-to

Once the build has completed successfully, a usable Tomcat installation will have been produced in the${tomcat.source}/output/build directory, and can be started and stopped with the usual scripts.

Building with Eclipse

IMPORTANT: This is not a supported means of building Tomcat; this information is provided without warranty :-). The only supported means of building Tomcat is with the Ant build described above. However, some developers like to work on Java code with a Java IDE, and the following steps have been used by some developers.

NOTE: This will not let you build everything under Eclipse; the build process requires use of Ant for the many stages that aren't simple Java compilations. However, it will allow you to view and edit the Java code, get warnings, reformat code, perform refactorings, run Tomcat under the IDE, and so on.

WARNING: Do not forget to create and configure ${tomcat.source}/build.properties file as described above before running any Ant targets.

Sample Eclipse project files and launch targets are provided in the res/ide-support/eclipse directory of the source tree. The instructions below will automatically copy these into the required locations.

An Ant target is provided as a convenience to download all binary dependencies, and to create the Eclipse project and classpath files in the root of the source tree. 

cd ${tomcat.source}
ant ide-eclipse

Start Eclipse and create a new Workspace.

Open the Preferences dialog and then select Java->Build Path->Classpath Variables to add two new Classpath Variables:

TOMCAT_LIBS_BASE The same location as the base.path setting in build.properties, where the binary dependencies have been downloaded
ANT_HOME the base path of Ant 1.8.1 or later

Use File->Import and choose Existing Projects into Workspace. From there choose the root directory of the Tomcat source tree (${tomcat.source}) and import the Tomcat project located there.

start-tomcat and stop-tomcat launch configurations are provided in res/ide-support/eclipse and will be available in the Run->Run Configurations dialog. Use these to start and stop Tomcat from Eclipse. 
If you want to configure these yourself (or are using a different IDE) then use org.apache.catalina.startup.Bootstrap as the main class, start/stop etc. as program arguments, and specify -Dcatalina.home=... (with the name of your build directory) as VM arguments.

Tweaking a few formatting preferences will make it much easier to keep consistent with Tomcat coding conventions (and have your contributions accepted):

Java -> Code Style -> Formatter -> Edit... Tab policy: Spaces only
Tab and Indentation size: 4
General -> Editors -> Text Editors Displayed tab width: 2
Insert spaces for tabs
Show whitespace characters (optional)
XML -> XML Files -> Editor Indent using spaces
Indentation size: 2
Ant -> Editor -> Formatter Tab size: 2
Use tab character instead of spaces: unchecked
Building with other IDEs

The same general approach should work for most IDEs; it has been reported to work in IntelliJ IDEA, for example.

原文地址:http://tomcat.apache.org/tomcat-7.0-doc/building.html#Building_with_Eclipse

Building Tomcat7 source step by step---官方文档的更多相关文章

  1. hbase官方文档(转)

    FROM:http://www.just4e.com/hbase.html Apache HBase™ 参考指南  HBase 官方文档中文版 Copyright © 2012 Apache Soft ...

  2. HBase官方文档

    HBase官方文档 目录 序 1. 入门 1.1. 介绍 1.2. 快速开始 2. Apache HBase (TM)配置 2.1. 基础条件 2.2. HBase 运行模式: 独立和分布式 2.3. ...

  3. 《Apache Velocity用户指南》官方文档

    http://ifeve.com/apache-velocity-dev/ <Apache Velocity用户指南>官方文档 原文链接   译文连接 译者:小村长  校对:方腾飞 Qui ...

  4. 【翻译】Django Channels 官方文档 -- Tutorial

    Django Channels 官方文档 https://channels.readthedocs.io/en/latest/index.html 前言: 最近课程设计需要用到 WebSocket,而 ...

  5. Kotlin开发语言文档(官方文档)-- 目录

    开始阅读Kotlin官方文档.先上文档目录.有些内容还未阅读,有些目录标目翻译还需琢磨琢磨.后续再将具体内容的链接逐步加上. 文档链接:https://kotlinlang.org/docs/kotl ...

  6. cppunit官方文档浅析

    使用doxygen生成官方文档 cppunit使用了doxygen作为它的文档建设工具,所以我们要找的“官方文档”,其实就在cppunit的代码里面. 请先参考博文<下载doxygen>( ...

  7. OGR 官方文档

    OGR 官方文档 http://www.gdal.org/ogr/index.html The OGR Simple Features Library is a C++ open source lib ...

  8. Matlab最新的官方文档中文翻译

    文章翻译的是Matlab最新的官方文档R2016b,可能后续如果我还有时间会继续翻译,希望能够帮到大家,翻译的不好请大家不要吐槽. Matlab官方文档地址:http://cn.mathworks.c ...

  9. OpenGL ES着色器语言之语句和结构体(官方文档第六章)内建变量(官方文档第七、八章)

    OpenGL ES着色器语言之语句和结构体(官方文档第六章) OpenGL ES着色器语言的程序块基本构成如下: 语句和声明 函数定义 选择(if-else) 迭代(for, while, do-wh ...

  10. Spring Data Commons 官方文档学习

    Spring Data Commons 官方文档学习   -by LarryZeal Version 1.12.6.Release, 2017-07-27 为知笔记版本在这里,带格式. Table o ...

随机推荐

  1. "git add -A" is equivalent to "git add .; git add -u".

    git add -A stages All git add . stages new and modified, without deleted git add -u stages modified ...

  2. Kernel Bypass & Offload 介绍

    系统网络优化可以有两方面的工作可以做:1 绕开内核(bypass):2 用硬件替代软件(offload). 具体包括: 1. 绕开内核: 不使用内核内核子系统的功能,采用自己实现的相同功能的代码来处理 ...

  3. 【关于JavaScript】自动计算的实例

    在一些贸易业务Web系统中,某些页面需要提供实时的辅助计算功能,例如:员工录入货物的单价和数量的值,通过JavaScript的事件处理可以直接显示出总价. 如下图所示就是本例的运行效果图: 本例中也采 ...

  4. 一步一步自定义SpringMVC参数解析器

    随心所欲,自定义参数解析器绑定数据. 题图:from Zoommy 干货 SpringMVC解析器用于解析request请求参数并绑定数据到Controller的入参上. 自定义一个参数解析器需要实现 ...

  5. leetcode面试准备: Jump Game II

    1 题目 Given an array of non-negative integers, you are initially positioned at the first index of the ...

  6. xcode5 ios7升级后的一系列问题解决

    framework not found IOKit解决办法,打开终端:cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS. ...

  7. hadoop2.0 eclipse 源码编译

    在eclipse下编译hadoop2.0源码 http://www.cnblogs.com/meibenjin/archive/2013/07/05/3172889.html hadoop cdh4编 ...

  8. 【HDOJ】3221 Brute-force Algorithm

    归来吧很好推导.T(n) = a^f(n-1)*b^f(n)%p.主要难点在于求mod和fibo.引用如下公式A^B%C = A^(B%phi(C) + phi(C))%C, 满足B>=phi( ...

  9. ☀【Zepto】touch events

    https://github.com/madrobby/zepto jTouchhttps://github.com/liutian1937/jTouch iphone.ipod Touch.ipad ...

  10. 【转】Ubuntu14.04搭建安装svnserver

    原文网址:http://www.cnblogs.com/blfshiye/p/5168028.html 前两天,公司准备搭建一个svnserver,供大家使用.于是.就先装了一个Ubuntu系统,然后 ...