日期:2014-05-19  浏览次数:20688 次

使用ANT把J2EE工程发布到Tomcat里
本人在clipse中使用的
<?xml version="1.0" encoding="UTF-8"?>

<project name="s2" default="打包" basedir=".">

<property file="build.properties"/>
<property environment="env"/>

<target name="clean" description="Delete this project!!">
<echo message="${env.JAVA_HOME}"/>
<delete dir="${build.home}"/>
<delete dir="${dist.home}"/>
</target>

<target name="init" depends="clean" description="This is mkdir target">
<mkdir dir="${build.home}"/>
</target>

<target name="compile" depends="init" description="This is compile the JAVA SOURCE!!">
<mkdir dir="${build.home}/WEB-INF/classes"/>
<javac srcdir="${source.home}"
destdir="${build.home}/WEB-INF/classes">
<classpath>
<path>
<fileset dir="${lib.home}"/>
</path>
</classpath>
</javac>
</target>

<target name="build" depends="compile" description="Copy all no JAVA class to build directory!!!">
<copy todir="${build.home}">
<fileset dir="${app.home}" excludes="**/*.class" />
</copy>

<copy todir="${build.home}/WEB-INF/classes">
<fileset dir="${source.home}" excludes="**/*.java"/>
</copy>
</target>

<target name="打包" depends="build" description="打成war包">
<mkdir dir="${dist.home}"/>
<jar destfile="${dist.home}/${pro.home}.war"
basedir="${build.home}"/>
</target>
</project>
1 楼 wahyd4 2011-05-23  
这个应该不难啊。。如何发布到远程呢?
2 楼 侯上校 2011-05-23  
这个还没搞过呢
3 楼 wangyu1221 2011-05-25  
用ftp传的人路过……= =
4 楼 侯上校 2011-06-27  
如果编译的时候含有Servlet的话,在classpath的path里加入tomcat路经,脑残体如下:<classpath>
<path>
<fileset dir="${lib.home}"/>
<fileset dir="${tomcat.home}/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${tomcat.home}/bin">
<include name="*.jar"/>
</fileset>
</path>
</classpath>
5 楼 侯上校 2011-06-27  
我的Tomcat路经为:tomcat.home=D:/deploy/apache-tomcat-6.0.29/