Title: Eclipse + Tomcat + ant note
Author: jrq
Link: http://blog.csdn.net/jrq/archive/2006/07/10/901264.aspx
Question: Eclipse 3 + Tomcat 5 is a great solution. However, it is troublesome to manually deploy to Tomcat each time during debugging. Now ant is used.
1. Open eclipse and create the builds. xml file under the root path of the project.
This is the key to ant configuration. The content is as follows:
-----------------
<? XML version = "1.0"?>
<Project name = "webmodulebuilder" default = "deploy" basedir = ".">
<! -- Set global properties for this build -->
<! -- Publish the web path -->
<Property name = "deploy_path" value = "D:/tomcat 5.0/webapps/dt"/>
<! -- Source web path -->
<Property name = "web_path" value = "D:/Eclipse/workspace/test/dt"/>
<! -- Path of the jar package compiled by the source -->
<Property name = "jar_path" value = "D:/Eclipse/workspace/test/DT/WEB-INF/lib"/>
<! -- Source Java file path -->
<Property name = "scr_path" value = "D:/Eclipse/workspace/test/src"/>
<! -- Source class file path -->
<Property name = "class_path" value = "D:/Eclipse/workspace/test/DT/WEB-INF/classes"/>
<! -- Define classpath -->
<Path id = "lib_class_path">
<Fileset file = "$ {jar_path}/*. Jar"/>
<Pathelement Path = "$ {class_path}"/>
</Path>
<! -- Preliminary Test -->
<Target name = "init">
<Mkdir dir = "$ {deploy_path}"/>
<Mkdir dir = "$ {deploy_path}/WEB-INF"/>
<Mkdir dir = "$ {deploy_path}/WEB-INF/classes"/>
<Mkdir dir = "$ {deploy_path}/WEB-INF/lib"/>
</Target>
<! -- Compile class -->
<Target name = "compile" depends = "init" Description = "compile the source files">
<Mkdir dir = "$ {class_path}"/>
<Javac srcdir = "$ {scr_path}" destdir = "$ {class_path}">
<Classpath refID = "lib_class_path"/>
</Javac>
</Target>
<! -- Copy publish -->
<Target name = "deploy" depends = "init, compile">
<Copy todir = "$ {deploy_path}">
<Fileset dir = "$ {web_path}">
<Include name = "**/*. *"/>
<Exclude name = "**/jsp_servlet/*. Class"/>
<Exclude name = "**/build. xml"/>
<Exclude name = "**/deploy. xml"/>
<Exclude name = "**/build. properties"/>
<Exclude name = "**/servers. xml"/>
<Exclude name = "**/targets. xml"/>
<Exclude name = "**/*. War"/>
</Fileset>
</Copy>
</Target>
</Project>
-----------------
2. Right-click the project and select "properties -- builder ". Click "new ".
3. In the select Configuration type window, click Select ant build and click OK ".
4. Configure the properties of the builder and enter the builder's "name ".
In the "Main" Page, select "Build File", select builds. xml Just configured, and "Basic directory" select the project root directory.
In "build options", select "during Automatic Build ".
5. Click "OK" to complete the configuration.
6. Select the ant builder you just created in the builder in the Project Properties and deselect the Java builder check box ". Click OK ".
7. During system debugging, ant will automatically compile and release the file to the specified directory. Great!
[-End-]
by jrq
2006/07/10 Yu Sui