Restarting Tomcat everytime I deployed with the Lomboz Eclipse plugin was proving to be too lengthy, so I set out trying to customize Ant a bit.
The following files were edited from the Lomboz generated webapp defaults. ie: create a project and edit the files found under WEB-INF.
The generated Ant config files copy all the compiled classes (redundant), the plain JSPs and all directories under WEB-INF to a temporary space jars it all up and copies that JAR to the webapp folder in tomcat. I didn’t want that. I just want the directory structure to be copied so that I can make changes faster and shorten my testing lifecycle (ooo buzzword).
Here’s my build.properties:
domain = /home/chris/jakarta-tomcat-4.1.12-LE-jdk14/webapps serverhome = /home/chris/jakarta-tomcat-4.1.12-LE-jdk14/ build = ../../acronym/WEB-INF/classes webapp = acronym
And here’s my build.xml:
<project name="AcronymChallenge" default="deploy" basedir=".">
<!-- set global properties for this build -->
<property file="build.properties"/>
<property name="dist" value="${domain}/${webapp}" />
<property name="web" value="../" />
<target name="init">
<!-- Create the dist directory structure used by compile
and copy the deployment descriptors into it-->
<mkdir dir="${dist}"/>
<mkdir dir="${dist}/WEB-INF"/>
<mkdir dir="${dist}/WEB-INF/classes"/>
<mkdir dir="${dist}/WEB-INF/lib"/>
<copy todir="${dist}">
<fileset dir="${web}">
<include name="**/*.*"/>
<exclude name="**/jsp_servlet/*.class"/>
<exclude name="**/build.xml"/>
<exclude name="**/build.properties"/>
<exclude name="**/servers.xml"/>
<exclude name="**/container.xml"/>
<exclude name="**/*.war"/>
</fileset>
</copy>
<copy todir="${dist}/WEB-INF/classes">
<fileset dir="${build}">
<include name="**/*.*"/>
<exclude name="**/jsp_servlet/*.class"/>
</fileset>
</copy>
</target>
<target name="deploy" depends="undeploy,init" >
<copy todir="${dist}">
<fileset dir="${web}">
<include name="**/*.*"/>
<exclude name="**/jsp_servlet/*.class"/>
<exclude name="**/build.xml"/>
<exclude name="**/build.properties"/>
<exclude name="**/servers.xml"/>
<exclude name="**/container.xml"/>
<exclude name="**/*.war"/>
</fileset>
</copy>
<copy todir="${dist}/WEB-INF/classes">
<fileset dir="${build}">
<include name="**/*.*"/>
<exclude name="**/jsp_servlet/*.class"/>
</fileset>
</copy>
</target>
<target name="undeploy">
<!-- Tomcat -->
<delete dir="${domain}/${webapp}"/>
<!-- Tomcat 4.0.x-->
<delete dir="${serverhome}/work/localhost/${webapp}"/>
<!-- Tomcat 4.1.x-->
<delete dir="${serverhome}/work/Standalone/localhost/${webapp}"/>
</target>
</project>
Leave your Comment