meiping 发表于 2013-1-31 02:49:10

在Ant脚本中如何调用第三方程序

部署的时候经常要求重启tomcat服务器,下面以停止和启动tomcat为例演示如何在ant脚本中调用第三方程序(该build.xml文件位于
WEB-INF文件夹中,用来在linux中快速调试和编译web应用程序,避免在windows上开发之后每次都要打包上传)
 
 
<?xml version="1.0" encoding="GBK"?><project name="csknow" default="all" basedir=".">       <!-- 全局属性 -->       <property name="csknow.dir" value="./" />       <property name="src.dir" value="${csknow.dir}/src" />       <property name="lib.dir" value="${csknow.dir}/lib" />       <property name="class.dir" value="${csknow.dir}/classes" />       <!-- 停止tomcat -->       <target name="stoptomcat">         <exec executable="sh">         <arg line="-c 'cd /usr/local/tomcat/bin; /usr/local/tomcat/bin/shutdown.sh'"/>         </exec>       </target>       <!-- 清理历史文件 -->       <target name="clean" depends="stoptomcat">               <delete dir="${class.dir}" />       </target>       <!-- 编译java源代码 -->       <target name="compile" depends="clean">               <mkdir dir="${class.dir}" />               <javac srcdir="${src.dir}" destdir="${class.dir}"encoding="GBK" debug="true">                     <classpath>                               <fileset dir="${lib.dir}">                                       <include name="*.jar"/>                               </fileset>                     </classpath>               </javac>       </target>       <!-- 复制配置文件 -->       <target name="copyconfig" depends="compile">               <copy todir="${class.dir}">                     <fileset dir="${src.dir}">                               <include name="*.xml" />                               <include name="*.properties" />                     </fileset>               </copy>       </target>       <!-- 启动tomcat -->       <target name="starttomcat" depends="copyconfig">         <exec executable="sh">         <arg line="-c 'cd /usr/local/tomcat/bin; /usr/local/tomcat/bin/startup.sh'"/>         </exec>       </target>       <target name="all" depends="starttomcat" /></project>
页: [1]
查看完整版本: 在Ant脚本中如何调用第三方程序