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:

# ----- 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=/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. 简单python2.7.3安装setuptools模块

    下载setuptools https://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg 安装 .6c11- ...

  2. sql update from 修改一个表的值来自另一个表

    假设有桌子表名 icate_table_set(table_id,table_name,table_state_id,store_id), 桌子状态表名icate_table_state(state_ ...

  3. 配置公网的域名绑定IP

    1. 在万网.美橙申请了一个域名,当然付完费了.   2. 点击"管理",找到了域名解析   3. 点击"域名解析"   注意"记录值",这 ...

  4. matlab读取指定路径下的图像

    利用matlab读取指定路径下的图像 %% 读入指定路径imgFolder下的图像imgName imgFolder = 'F:\博\快盘\图像+数据\images\文章实验图'; %指定路径 img ...

  5. java答疑

    问 什么是 Java 的字节码? 答 它是程序的一种低级表示,可以运行于 Java 的虚拟机.将程序抽象为字节码可以保证 Java 程序员的 代码能够运行在各种设备之上. 问 Java 允许整型溢出并 ...

  6. bzoj 1191: [HNOI2006]超级英雄Hero 并查集 || 匈牙利算法

    1191: [HNOI2006]超级英雄Hero Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1804  Solved: 850[Submit][S ...

  7. cademy的Java习题做后感

    在cademy各种语言的hello world也做了不少,好像都差不多,先是数据类型,然后条件语句,之后面向对象,再上几个特殊对象. 以前都没有做笔记,导致ruby做完就忘光了,这次好歹写点什么,比如 ...

  8. php生成的中文文件名会变成乱码,应该这样解决

    现在php有很多类库,会生成文件,比如生成zip文件,生成二维码等等.这些类库用起来很爽,但是一旦生成带有中文的文件名,极有可能出现乱码. 问题:生成的中文文件名会变成乱码 解决:使用函数:iconv ...

  9. Java实现生产者消费者

    方法1:最简单--利用LinkedBlockingQueue 队列具有先进先出的特点,成为经常应用于生产-消费者模式的数据结构. 1.将一个对象放到队列尾部,如果队列已满,就等待直到有空闲节点. —— ...

  10. 利用ROWID快速执行关联更新

    一.构造相关表P1,P2 create table p1(id int,name char(10)); create table p2(id int,name char(10)); 二.批量插入数据 ...