我正在使用下面提到的 ant 构建脚本部署我的应用程序。我的应用程序部署在我的 ant 脚本中提到的指定服务器上。但我想在部署新项目之前收回远程服务器上现有的部署项目。这是我的蚂蚁脚本。
<?xml version="1.0"?>
<project name="xyz" basedir="." default="deploy">
<!-- Read values from buildscript properties file -->
<property file="buildscript.properties" />
<!-- set global variable for this build -->
<property name="build" value="${basedir}/build"/>
<property name="src.dir" value="src"/>
<property name="build.dir" value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="war.dir" value="${build.dir}/war"/>
<!-- Configure the context path for this application -->
<property name="path" value="/xyz"/>
<!-- set class path -->
<path id="compile.classpath">
<fileset dir="WebContent/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${tomcatDir}">
<include name="*.jar"/>
</fileset>
</path>
<!-- Configure the custom Ant tasks for the Tomcat Server Manager -->
<taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask">
<classpath refid="compile.classpath" />
</taskdef>
<taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask">
<classpath refid="compile.classpath" />
</taskdef>
<taskdef name="start" classname="org.apache.catalina.ant.StartTask">
<classpath refid="compile.classpath" />
</taskdef>
<taskdef name="stop" classname="org.apache.catalina.ant.StopTask">
<classpath refid="compile.classpath" />
</taskdef>
<!-- delete build directory -->
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<!-- create classes, war directory in build -->
<target name="create" depends="clean">
<mkdir dir="${classes.dir}"/>
<mkdir dir="${war.dir}"/>
</target>
<!-- compile source code and put classes in classes dir -->
<target name="compile" depends="create">
<copy todir="${classes.dir}" overwrite="true">
<fileset dir="src" excludes="*.java"/>
</copy>
<!-- for replacing cfg file to deploy on stagging-->
<copy todir="${classes.dir}" overwrite="true">
<fileset dir="${configurationFileDir}">
<include name="*.xml"/>
</fileset>
</copy>
<javac destdir="${classes.dir}" srcdir="${src.dir}" debug="true">
<classpath refid="compile.classpath"/>
</javac>
</target>
<!-- create war file -->
<target name="war" depends="compile">
<war destfile="${war.dir}/xyz.war" webxml="WebContent/WEB-INF/web.xml">
<fileset dir="WebContent"/>
<classes dir="build/classes"/>
</war>
</target>
<!-- Deploy war file -->
<target name="deploy" description="Install web application"
depends="war">
<deploy url="${url}" username="${username}" password="${password}"
path="${path}" war="file:${war.dir}/xyz.war"/>
</target>
<!-- Start apllication -->
<target name="start" description="start application in tomcat">
<start url="${url}" username="${username}" password="${password}" path="${path}"/>
</target>
<!-- Undeploy war file -->
<target name="undeploy" description="Remove web application" >
<undeploy url="${url}" username="${username}" password="${password}"
path="${path}"/>
</target>
<!-- Stop apllication -->
<target name="stop" description="stop application in tomcat">
<stop url="${url}" username="${username}" password="${password}" path="${path}"/>
</target>
</project>