|
参考tomcat文档,可以从源码安装最新的cvs版本的tomcat,方法非常easy,体现了ant的强大功能。
我安装全部使用普通用户。
在个人目录下建以下几个目录:
tomcat-src#用于存放tomcat源代码
tomcat-current#用于存放编译好的tomcat二进制代码
java#存放tomcat编译时依赖的java包
确保你已经安装了jdk,ant,cvs。
进入tomcat-src目录中,新建两个文件:build.xml 和build.properties
#cd tomcat-src
#<editor> build.xml
输入以下见容:
<project name="Tomcat 5.0 Netbuild" default="build" basedir=".">
<!-- ===================== Initialize Property Values =================== -->
<!-- See "build.properties.sample" in the top level directory for all -->
<!-- property values you must customize for successful building!!! -->
<property file="${user.home}/build.properties"/>
<property file="build.properties"/>
<property file="build.properties.default"/>
<!-- Project Properties -->
<property name="name" value="Apache Tomcat" />
<property name="year" value="2003" />
<property name="version" value="5.0" />
<property name="project" value="jakarta-tomcat" />
<property name="final.name" value="${project}-${version}" />
<property name="final-src.name" value="${project}-${version}-src" /
<!-- CVSROOT -->
<property name="cvsroot"
value=":pserver:anoncvs@cvs.apache.org:/home/cvspublic" />
<!-- Subprojects -->
<property name="api.project" value="jakarta-servletapi-5" />
<property name="tomcat.project" value="jakarta-tomcat-5" />
<property name="catalina.project" value="jakarta-tomcat-catalina" />
<property name="jtc.project" value="jakarta-tomcat-connectors" />
<property name="jasper.project" value="jakarta-tomcat-jasper" />
<!-- Dependent projects -->
<property name="commons-daemon.project" value="jakarta-commons/daemon" />
<!-- Source dependencies -->
<property name="api.home"
value="${basedir}/${api.project}"/>
<property name="catalina.home"
value="${basedir}/${catalina.project}"/>
<property name="jasper.home"
value="${basedir}/${jasper.project}/jasper2"/>
<property name="jtc.home"
value="${basedir}/${jtc.project}"/>
<property name="tomcat.home"
value="${basedir}/${tomcat.project}"/>
<target name="build" depends="check.source,check.source.depends,get.source,get.source.depends"
description="Builds all components">
<ant dir="${tomcat.home}" target="download" />
<ant dir="${tomcat.home}" target="deploy" />
</target>
<target name="checkout"
description="Update or checkout required sources from CVS">
<echo level="info"
message="If the checkout fails, run `cvs -d ${cvsroot} login` and try again. The password for the anonymous CVS access is `anoncvs`" />
<cvs cvsroot="${cvsroot}" quiet="true"
command="checkout -P ${tomcat.project}"
dest="${basedir}" compression="true" />
<cvs cvsroot="${cvsroot}" quiet="true"
command="checkout -P ${catalina.project}"
dest="${basedir}" compression="true" />
<cvs cvsroot="${cvsroot}" quiet="true"
command="checkout -P ${jasper.project}"
dest="${basedir}" compression="true" />
<cvs cvsroot="${cvsroot}" quiet="true"
command="checkout -P ${jtc.project}"
dest="${basedir}" compression="true" />
<cvs cvsroot="${cvsroot}" quiet="true"
command="checkout -P ${api.project}"
dest="${basedir}" compression="true" />
</target>
<target name="checkout.depends"
description="Update or checkout dependent sources from CVS">
<cvs cvsroot="${cvsroot}" quiet="true"
command="checkout -P jakarta-commons/LICENSE"
dest="${basedir}" compression="true" />
<cvs cvsroot="${cvsroot}" quiet="true"
command="checkout -P ${commons-daemon.project}"
dest="${basedir}" compression="true" />
</target>
<!-- *************** UTILITY TARGETS *************** -->
<target name="check.source">
<available property="source.exists"
file="${basedir}/${tomcat.project}" type="dir" />
</target>
<target name="check.source.depends">
<available property="source.depends.exists"
file="${basedir}/${commons-daemon.project}" type="dir" />
</target>
<target name="get.source" unless="source.exists">
<antcall target="checkout" />
</target>
<target name="get.source.depends" unless="source.depends.exists">
<antcall target="checkout.depends" />
</target>
</project>
build.properties内容如下:
base.path=/home/hantsy/java
运行ant checkout来下载最新的tomcat源代码,运行ant build会从www.apache.org上下载tomcat 依赖的包,并对tomcat进行编译。
好了,根据网络情况,编译的时间长短也不一样。最快时我只用了6分钟。
编译完后,进入jakarta-tomcat-5目录:
#cd jakarta-tomcat-5
#cd build
#cp -fR * ~/tomcat-current
一份最新鲜的tomcat就生成了。 |
|