Looks like the Struts portion of this Wiki is still in it's early stages, so I won't presume to impose too much structure at this point. I've found the use of a whiteboard Wiki page to be useful for working out ideas that may later have their own pages. --DarinHawley
First, here's an excellent tutorial on Struts development with Eclipse (http://jakarta.apache.org/struts/faqs/eclipse.html), by JamesMitchell. I provide the following only because I had some problems getting his version of build.xml to work (specifically a Missing message for key index.title error message due to resources not being copied). I also prefer the Tomcat style build process (http://jakarta.apache.org/tomcat/tomcat-4.1-doc/appdev). This is still a work in progress...
Struts 1.1 RC 1, Tomcat 4.1.24, Eclipse 2.1.0
I'll expand these later...
- Configure Tomcat as an External Tool in Eclpise.
- Create skeleton project with src, docs, web and build.xml.
- Customize build.xml with project/app name, catalina home, and manager username/password.
- Add $CATALINA_HOME/server/lib/catalina-ant.jar to Ant config.
- Start Tomcat, Run Ant with install target.
<!--
{{{ Removed comments and slightly modified from original at...
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/appdev/build.xml.txt
Requires CATALINA_HOME environment variable set
and $CATALINA_HOME/server/lib/catalina-ant.jar in CLASSPATH. -->
<project name="StrutsTest" default="compile" basedir=".">
{{{ <property environment="env"/> <!-- ADDED -->
<property file="build.properties"/> <property file="${user.home}/build.properties"/>
<property name="app.name" value="${ant.project.name}"/> <!-- CHANGED --> <property name="app.path" value="/${app.name}"/> <property name="app.version" value="0.1-dev"/> <property name="build.home" value="${basedir}/build"/> <property name="catalina.home" value="${env.CATALINA_HOME}"/> <!-- CHANGED --> <property name="dist.home" value="${basedir}/dist"/> <property name="docs.home" value="${basedir}/docs"/> <property name="manager.url" value="http://localhost:8080/manager"/> <property name="src.home" value="${basedir}/src"/> <property name="web.home" value="${basedir}/web"/>
<property name="manager.username" value="tcadmin"/> <!-- ADDED --> <property name="manager.password" value="tst101"/> <!-- ADDED -->
<taskdef name="install" classname="org.apache.catalina.ant.InstallTask"/> <taskdef name="list" classname="org.apache.catalina.ant.ListTask"/> <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"/> <taskdef name="remove" classname="org.apache.catalina.ant.RemoveTask"/>
<property name="compile.debug" value="true"/> <property name="compile.deprecation" value="false"/> <property name="compile.optimize" value="true"/> }}}
<!-- Dummy external dependency --> <!-- {{{ <property name="foo.jar"
value="/path/to/foo.jar"/> }}}
-->
{{{ <path id="compile.classpath">
<!-- Include all JAR files that will be included in /WEB-INF/lib --> <!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** --> }}}
<!-- <pathelement location="${foo.jar}"/> -->
{{{ <!-- Include all elements that Tomcat exposes to applications -->
<pathelement location="${catalina.home}/common/classes"/> <fileset dir="${catalina.home}/common/endorsed">
<include name="*.jar"/>
</fileset> <fileset dir="${catalina.home}/common/lib">
<include name="*.jar"/>
</fileset> <pathelement location="${catalina.home}/shared/classes"/> <fileset dir="${catalina.home}/shared/lib">
<include name="*.jar"/>
</fileset>
</path>
<target name="all" depends="clean,compile"
description="Clean build and dist directories, then compile"/>
<target name="clean"
description="Delete old build and dist directories">
<delete dir="${build.home}"/> <delete dir="${dist.home}"/>
</target>
<target name="compile" depends="prepare"
description="Compile Java sources">
<!-- Compile Java classes as necessary --> <mkdir dir="${build.home}/WEB-INF/classes"/> <javac srcdir="${src.home}"
- destdir="${build.home}/WEB-INF/classes"
- debug="${compile.debug}"
- deprecation="${compile.deprecation}"
optimize="${compile.optimize}">
<classpath refid="compile.classpath"/>
</javac>
<!-- Copy application resources --> <copy todir="${build.home}/WEB-INF/classes">
<fileset dir="${src.home}" excludes="**/*.java"/>
</copy>
- destdir="${build.home}/WEB-INF/classes"
</target>
<target name="dist" depends="compile,javadoc"
description="Create binary distribution">
<!-- Copy documentation subdirectories --> <mkdir dir="${dist.home}/docs"/> <copy todir="${dist.home}/docs">
<fileset dir="${docs.home}"/>
</copy>
<!-- Create application JAR file --> <jar jarfile="${dist.home}/${app.name}-${app.version}.war"
basedir="${build.home}"/>
<!-- Copy additional files to ${dist.home} as necessary -->
</target>
<target name="install" depends="compile"
description="Install application to servlet container">
<install url="${manager.url}"
- username="${manager.username}" password="${manager.password}"
- path="${app.path}"
- username="${manager.username}" password="${manager.password}"
</target>
<target name="javadoc" depends="compile"
description="Create Javadoc API documentation">
<mkdir dir="${dist.home}/docs/api"/> <javadoc sourcepath="${src.home}"
- destdir="${dist.home}/docs/api"
packagenames="*">
<classpath refid="compile.classpath"/>
</javadoc>
</target>
<target name="list"
description="List installed applications on servlet container">
<list url="${manager.url}"
- username="${manager.username}"
password="${manager.password}"/>
- username="${manager.username}"
</target>
<target name="prepare">
<!-- Create build directories as needed --> <mkdir dir="${build.home}"/> <mkdir dir="${build.home}/WEB-INF"/> <mkdir dir="${build.home}/WEB-INF/classes"/>
<!-- Copy static content of this web application --> <copy todir="${build.home}">
<fileset dir="${web.home}"/>
</copy>
<!-- Copy external dependencies as required --> <!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** --> <mkdir dir="${build.home}/WEB-INF/lib"/> }}}
<!-- <copy todir="${build.home}/WEB-INF/lib" file="${foo.jar}"/> -->
{{{ <!-- Copy static files from external dependencies as needed -->
<!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
</target>
<target name="reload" depends="compile"
description="Reload application on servlet container">
<reload url="${manager.url}"
- username="${manager.username}" password="${manager.password}"
path="${app.path}"/>
- username="${manager.username}" password="${manager.password}"
</target>
<target name="remove"
description="Remove application on servlet container">
<remove url="${manager.url}"
- username="${manager.username}" password="${manager.password}"
path="${app.path}"/>
- username="${manager.username}" password="${manager.password}"
</target> }}}
</project>
- }}}