<?xml version="1.0" encoding="UTF-8"?>
<project
name="XX" basedir="." default="deploy">
<!-- properties -->
<property name="tomcat.home" value="tomcat_path">
</property>
<property name="project.name" value="project_name">
</property>
<property name="project.context" value="WebRoot/WEB-INF">
</property>
<!-- classpath in project -->
<path id="project.class.path"><fileset dir="${project.context}/lib">
<include name="**/*.jar"/>
</fileset>
</path>
<!-- clean task-->
<target name="clean">
<delete dir="build"/>
<delete includeemptydirs="true">
<fileset dir="${project.context}/classes" includes="**/*" defaultexcludes="false"/>
</delete>
<delete dir="${tomcat.home}/webapps/${project.name}"/>
<delete file="${tomcat.home}/webapps/${project.name}.war"/>
</target>
<!-- compile task -->
<target name="compile" depends="clean" >
<javac srcdir="src" destdir="${project.context}/classes" >
<classpath refid="project.class.path" />
</javac>
<copy todir="${project.context}/classes" >
<fileset dir="src" >
<exclude name="**/*.java" />
</fileset>
</copy>
</target>
<!-- create folders -->
<target name="build" >
<mkdir dir="build" />
</target>
<!-- package -->
<target name="package" depends="compile,build" >
<jar destfile="build/${project.name}.war" >
<fileset dir="WebRoot/" >
<include name="**/*" />
<!-- 打包时不包括的文件夹
<exclude name="**/com/XX/XX/XX/XX/" />
打包时不包括的jar包 <exclude name="**/XX.jar/>
-->
</fileset>
</jar>
</target>
<!-- deploy project -->
<target name="deploy" depends="package">
<copy file="build/${project.name}.war" todir="${tomcat.home}/webapps">
</copy>
</target>
<!-- start tomcat -->
<target name="tomcat.start" depends="deploy">
<java jar="${tomcat.home}/bin/bootstrap.jar" fork="true">
<jvmarg value="-Dcatalina.home=${tomcat.home}"/>
</java>
</target>
<!-- stop tomcat -->
<target name="tomcat.stop">
<java jar="${tomcat.home}/bin/bootstrap.jar" fork="true">
<jvmarg value="-Dcatalina.home=${tomcat.home}" />
<arg line="stop" />
</java>
</target>
</project>