Building TOMCAT7 Source Step by step---official documentation

Source: Internet
Author: User
Tags unpack apache tomcat

Table of Contents
  • Introduction
  • Download a Java development Kit (JDK) version 6
  • Install Apache Ant 1.8.1 or later
  • Checkout or obtain the source code for TOMCAT 7.0
  • Building Tomcat
  • Building with Eclipse
  • Building with other IDEs
Introduction

Building Apache Tomcat from Sou Rce is very easy, and are 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 JD K 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, the Ant release resides in its own directory (convent Ionally named  apache-ant-1.8.x ). For the remainder of the "This", the symbolic name  ${ant.home}  is used to refer to the full Pathnam E 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'll 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 the "This", the symbolic name is used to refer to the location ${tomcat.source} where the source has been placed .

Building Tomcat

Use the following commands to build Tomcat:

cd ${tomcat.source}
ant

WARNING: Running This command would download libraries required to build Tomcat to the /usr/share/java directory by default. On a typical Linux or Macox system, an ordinary user is not having access to write to this directory, and, even if you do, It is likely not appropriate for your to write there. On Windows This usually corresponds C:\usr\share\java to the directory, unless Cygwin is used. Read below to learn what 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 would have been produced ${tomcat.source}/output/build in the directory, and Can is started and stopped with the usual scripts.

Building with Eclipse

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

Note: This won't let you build everything under Eclipse; The build process requires use of Ant for the many stages this aren ' t simple Java compilations. However, it'll allow your to view and edit the Java code, get warnings, reformat code, perform refactorings, run Tomcat u NDEr the IDE, and so on.

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

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

An Ant target was provided as a convenience to download all binary dependencies, and to create the Eclipse project and Clas spath 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 new C4>classpath Variables:

Tomcat_libs_base The same location base.path build.properties as the setting in, where the binary dependencies has 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-tomcatand launch configurations is provided in and would be available in the stop-tomcat res/ide-support/eclipse run->run configurations dia Log. Use these to start and stop Tomcat from Eclipse.
If you want to configure these yourself (or is 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 would make it much easier to keep consistent with Tomcat coding conventions (and has Your contributions accepted):

Edit, Formatter, Java---Code Style-- Tab Policy:spaces only
Tab and Indentation Size:4
Text Editors, Editors, General Displayed Tab Width:2
Insert Spaces for tabs
Show whitespace characters (optional)
Editor, XML Files, XML Indent using spaces
Indentation Size:2
Formatter, Editor, Ant 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.

Original address: Http://tomcat.apache.org/tomcat-7.0-doc/building.html#Building_with_Eclipse

Building TOMCAT7 Source Step by step---official documentation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.