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. SEMAT[软件工程方法和理论 Software Engineering Method and Theory]

    Agile software development Agile software development is a group of software development methods bas ...

  2. 一个简单的webservice调用

    我们先创建一个简单空web应用程序 然后添加新建项目 //我们创建一个peson对象,产生数据标识返回 using System; using System.Collections.Generic; ...

  3. URL encode 与 URL decode 的C语言实现

    转载自:http://blog.csdn.net/langeldep/article/details/6264058 本文代码为从PHP代码中修改而来,只保留了2个函数. int php_url_de ...

  4. JDK的帮助文档

    1.JDK1.8在线api,英文版 https://docs.oracle.com/javase/8/docs/api/

  5. Book of Evil

    Codeforces Round #196 (Div. 2) D:http://codeforces.com/contest/337/status/D 题意:给你一个树,然后树中有一m个点,求到这m个 ...

  6. Android开源项目发现--- 效率开发工具篇(持续更新)

    1.Json2Java 根据JSon数据自动生成对应的Java实体类,还支持Parcel.Gson Annotations对应代码自动生成.期待后续的提取父类以及多url构建整个工程的功能 项目地址: ...

  7. c++重载、覆盖和隐藏

    看以前的:http://www.cnblogs.com/youxin/p/3305688.html 答案:a.成员函数被重载的特征:overload(1)相同的范围(在同一个类中):(2)函数名字相同 ...

  8. UVA 11624 Fire!(二次BFS)

    先对火BFS一次,求出每个点的最小着火时间. 再对人BFS一次,求出走到边界的最少时间. #include <iostream> #include <queue> #inclu ...

  9. 14.6.3.1 The InnoDB Buffer Pool

    14.6.3.1 The InnoDB Buffer Pool InnoDB 保持一个存储区域被称为buffer pool 用于cache数据和索引在内存里, 知道InnoDB buffer pool ...

  10. Android WebView JavaScript交互

    今天介绍一下,Android中Webview与JavaScript的交互,首先是在布局文件里添加webview控件: <WebView android:id="@+id/webview ...