通用ANT编译发布打包启动tomcat的模板


  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <!--  
  3.         ======================================================================  
  4.         
  5.         ======================================================================  
  6. -->  
  7. <project name="${project.name}" default="deploy" basedir=".">  
  8.     <!--将name的值改为对应工程的名字将default的值改为需要的缺省任务-->  
  9.     <!--  
  10.         app.name 发布的应用名 app.version 版本 build.home 编译目标位置 appserver.home  
  11.         tomcat根目录位置 deploy.home 部署位置 war.home war包位置 src.home src的位置  
  12.         src.webroot WebRoot的位置  
  13.     -->  
  14.     <property file="build.properties" />  
  15.     <property name="lib.home" value="${basedir}" />  
  16.     <property environment="env" />  
  17.     <property name="java.home" value="S{env.JAVA_HOME}" />  
  18.     <property name="ant.home" value="S{env.ANT_HOME}" />  
  19.     <!-- 路径设置 包括了jar文件才能编译-->  
  20.     <path id="compile.classpath">  
  21.         <!-- 项目lib下的所有jar -->
  22.         <fileset dir="${src.lib}">  
  23.             <include name="**/*.jar" />  
  24.         </fileset>  
  25.         <!-- 项目tomcat lib下的所有jar -->
  26. <fileset dir="${tomcat.lib}">
  27.             <include name="**/*.jar" />
  28.          </fileset>
  29.     </path>  
  30.   
  31.     <target name="test" description="description">  
  32.         <echo message="project.name=${project.name}" />  
  33.         <echo message="java.home=${java.home}" />  
  34.         <echo message="ant.home=${ant.home}" />  
  35.         <echo message="appserver.home=${appserver.home}" />  
  36.         <echo message="deploy.path=${deploy.path}" />  
  37.         <echo message="tomcat.manager.url=${tomcat.manager.url}" />  
  38.         <echo message="tomcat.manager.username=${tomcat.manager.username}" />  
  39.         <echo message="tomcat.manager.password=${tomcat.manager.password}" />  
  40.         <echo message="build.home=${build.home}" />  
  41.         <echo message="src.webroot=${src.webroot}" />  
  42.         <echo message="build.web-inf=${build.web-inf}" />  
  43.         <echo message="build.class=${build.class}" />  
  44.         <echo message="build.lib=${build.lib}" />  
  45.         <echo message="src.home=${src.home}" />  
  46.         <echo message="src.res=${src.res}" />  
  47.         <echo message="src.lib=${src.lib}" />  
  48.         <echo message="src.web-inf=${src.web-inf}" />  
  49.         <echo message="deploy.home=${deploy.home}" />  
  50.         <echo message="cache.home=${cache.home}" />  
  51.     </target>  
  52.   
  53.     <target name="clean" description="description">  
  54.         <delete dir="${deploy.home}" failοnerrοr="false" />  
  55.         <delete dir="${build.home}" failοnerrοr="false" />  
  56.         <delete file="${deploy.path}/${project.name}.war" failοnerrοr="false" />  
  57.     </target>  
  58.     <target name="init" depends="clean">  
  59.         <mkdir dir="${build.home}" />  
  60.         <mkdir dir="${build.web-inf}" />  
  61.         <mkdir dir="${build.class}" />  
  62.         <mkdir dir="${build.lib}" />  
  63.     </target>  
  64.   
  65.     <target name="prepare" depends="init">  
  66.         <copy todir="${build.home}">  
  67.             <fileset dir="${src.webroot}" />  
  68.         </copy>  
  69.     </target>  
  70.   
  71.     <target name="compile" depends="prepare">  
  72.         <echo message="start compile!" />  
  73.         <javac srcdir="${src.home}" destdir="${build.class}" debug="${compile.debug}" deprecation="${compile.deprecation}" optimize="$compile.optimize}">  
  74.             <classpath refid="compile.classpath" />  
  75.         </javac>  
  76.         <copy todir="${build.class}">  
  77.             <fileset dir="${src.res}">  
  78.                 <include name="**" />  
  79.             </fileset>  
  80.         </copy>  
  81.         <echo message="complete compile!" />  
  82.     </target>  
  83.   
  84.     <target name="deploy" depends="compile">  
  85.         <mkdir dir="${deploy.home}" />  
  86.         <copy todir="${deploy.home}">  
  87.             <fileset dir="${build.home}" />  
  88.         </copy>  
  89.         <echo message="Successful Deployment" />  
  90.     </target>  
  91.   
  92.     <target name="undeploy">  
  93.         <delete dir="${deploy.home}" />  
  94.         <delete dir="${cache.home}" />  
  95.         <echo message="Successful UnDeployment" />  
  96.     </target>  
  97.     <!--  
  98.         这也是一种打war包的方式  
  99.         =============================================================================  
  100.         <target name="jar" depends="compile">  
  101.             <jar jarfile="${deploy.path}/${project.name}.war" basedir="${build.home}" />  
  102.             <echo message="Successful packaging jar" />  
  103.         </target>  
  104.         =============================================================================  
  105.     -->  
  106.     <target name="deploywar" depends="compile" description="deploy the app as the war">  
  107.         <war destfile="${deploy.path}/${project.name}.war" webxml="${build.web-inf}/web.xml">  
  108.             <fileset dir="${build.home}">  
  109.                 <include name="**/*.*" />  
  110.             </fileset>  
  111.         </war>  
  112.     </target>  
  113.     <!--   
  114.         =============================================================================  
  115.         打包成jar   
  116.         =============================================================================  
  117.     -->  
  118.     <target name="jar" depends="compile" description="make .jar file">  
  119.         <delete dir="${doc.home}" />  
  120.         <mkdir dir="${doc.home}" />  
  121.         <jar destfile="${doc.home}/${project.name}.jar" basedir="${build.class}">  
  122.             <manifest>  
  123.                 <attribute name="Specification-Title" value="${project.name}-${doc.title}" />  
  124.                 <attribute name="Created-By" value="吴移风" />  
  125.                 <attribute name="Specification-Version" value="${app.version}" />  
  126.                 <attribute name="Specification-Vendor" value="${doc.vendor}" />  
  127.             </manifest>  
  128.         </jar>  
  129.     </target>  
  130.     <!--  
  131.         =============================================================================  
  132.         输出并打包api文档成rar   
  133.         =============================================================================  
  134.     -->  
  135.     <target name="doc" depends="jar,compile" description="create api doc">  
  136.         <echo message="Running API Doc ..." />  
  137.         <tstamp>  
  138.             <format property="current.year" pattern="yyyy" />  
  139.         </tstamp>  
  140.         <javadoc sourcepath="${src.home}" destdir="${doc.home}/${project.name}" author="true" version="true" use="true" doctitle="&lt;h1&gt;${project.name}-${doc.title}-${app.version}&lt;/h1&gt;" windowtitle="${project.name}-${doc.title}-${app.version}" bottom="Copyright &amp;copy; 1998-${current.year} - ${doc.vendor}">  
  141.             <classpath refid="compile.classpath" />  
  142.         </javadoc>  
  143.         <!-- 打包API文件和目录 -->  
  144.         <echo message="Compressing API Doc ..." />  
  145.         <zip destfile="${doc.home}/${project.name}-api.rar">  
  146.             <zipfileset dir="${doc.home}" prefix="${doc.name}" />  
  147.         </zip>  
  148.         <!-- 打包之后清除构建的API文件和目录以及classes目录 -->  
  149.         <echo message="Deleting classes ..." />  
  150.         <echo message="Deleting API Doc ..." />  
  151.     </target>  
  152.   
  153.     <!--   
  154.         =============================================================================  
  155.         tomcat task   
  156.         =============================================================================  
  157.     -->  
  158.     <taskdef name="install" classname="org.apache.catalina.ant.InstallTask">  
  159.         <classpath>  
  160.             <path location="${appserver.home}/lib/catalina-ant.jar" />  
  161.         </classpath>  
  162.     </taskdef>  
  163.     <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask">  
  164.         <classpath>  
  165.             <path location="${appserver.home}/lib/catalina-ant.jar" />  
  166.         </classpath>  
  167.     </taskdef>  
  168.     <taskdef name="list" classname="org.apache.catalina.ant.ListTask">  
  169.         <classpath>  
  170.             <path location="${appserver.home}/lib/catalina-ant.jar" />  
  171.         </classpath>  
  172.     </taskdef>  
  173.     <taskdef name="start" classname="org.apache.catalina.ant.StartTask">  
  174.         <classpath>  
  175.             <path location="${appserver.home}/lib/catalina-ant.jar" />  
  176.         </classpath>  
  177.     </taskdef>  
  178.     <taskdef name="stop" classname="org.apache.catalina.ant.StopTask">  
  179.         <classpath>  
  180.             <path location="${appserver.home}/lib/catalina-ant.jar" />  
  181.         </classpath>  
  182.     </taskdef>  
  183.     <target name="install" description="install the application in Tomcat">  
  184.         <install url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="${project.name}" war="${project.name}" />  
  185.     </target>  
  186.     <target name="reload" description="reload the application in Tomcat">  
  187.         <reload url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="${project.name}" />  
  188.     </target>  
  189.     <target name="list" description="list All the application in Tomcat">  
  190.         <list url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" />  
  191.     </target>  
  192.     <target name="start" description="start the application in Tomcat">  
  193.         <start url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${project.name}" />  
  194.     </target>  
  195.     <target name="stop" description="stop the application in Tomcat">  
  196.         <stop url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/PiccSystem" />  
  197.     </target>  
  198.       
  199.     <!--   
  200.         =============================================================================  
  201.         start tomcat  
  202.         =============================================================================  
  203.     -->  
  204.     <target name="start-tomcat-E">  
  205.         <exec executable="cmd" dir="${appserver.home}/bin">  
  206.             <arg value="/c" />  
  207.             <arg value="startup.bat" />  
  208.         </exec>  
  209.     </target>  
  210.   
  211.     <target name="stop-tomcat-E">  
  212.         <exec executable="cmd " dir="${appserver.home}/bin" spawn="true">  
  213.             <arg value="/c" />  
  214.             <arg value="shutdown.bat" />  
  215.         </exec>  
  216.     </target>  
  217.   
  218.     <target name="start-tomcat-D">  
  219.         <exec executable="cmd" dir="${casserver.home}/bin">  
  220.             <arg value="/c" />  
  221.             <arg value="startup.bat" />  
  222.         </exec>  
  223.     </target>  
  224.   
  225.     <target name="stop-tomcat-D">  
  226.         <exec executable="cmd " dir="${casserver.home}/bin" spawn="true">  
  227.             <arg value="/c" />  
  228.             <arg value="shutdown.bat" />  
  229.         </exec>  
  230.     </target>  
  231. </project>  


Java代码 
  1. project.name=PiccSystem  
  2. #----------------------------------------------------------    
  3. appserver.home=E:/apache-tomcat-6.0.14  
  4. casserver.home=E:/apache-tomcat-6.0.14  
  5. deploy.path=E:/apache-tomcat-6.0.14/webapps  
  6. tomcat.manager.url=http://localhost:8080/manager  
  7. tomcat.manager.username=ant
  8. tomcat.manager.password=secret
  9. build.home=build  
  10.   
  11. #------  
  12. app.version=1.0  
  13.   
  14. build.web-inf=build/WEB-INF  
  15. build.class=build/WEB-INF/classes  
  16. build.lib=build/WEB-INF/lib  
  17. src.webroot=WebRoot  
  18. src.home=src
  19. src.res=src
  20. src.lib=WebRoot/WEB-INF/lib  
  21. src.web-inf=WebRoot/WEB-INF  
  22. tomcat.lib=E:/apache-tomcat-6.0.14/lib
  23. deploy.home=E:/apache-tomcat-6.0.14/webapps/PiccSystem  
  24. cache.home=E:/apache-tomcat-6.0.14/work/Catalina/localhost  
  25.   
  26. doc.home=E:/doc  
  27. doc.title=API  
  28. doc.vendor=Stone Age Co. Ltd.   
  29.   
  30. compile.debug=true  
  31. compile.deprecation=false  
  32. compile.optimize=true  

说明:提供编译,发布到tomcat,打war包。启动tomcat,停止tomcat,我这里使用的是eclipse,所以编译路径是build,如果你不是请相应修改,project.name是发布到tomcat的名称,还有WebRoot/WebContent,就是这些目录,大家如果有不同,修改properties文件就好了。

1) 配置客户端 (tomcat 6)
将服务端的${CATALINA_HOME}/lib/catalina-ant.jar拷贝到客户端的${ANT_HOME}/lib 
客户端的${ANT_HOME}在本文中指的是D:\dev\eclipse\plugins\org.apache.ant_1.6.5\lib 
即eclipse自带的ant目录,为了让eclipse自带的ant能正常运行任务,你还得将这个jar添加到eclipse的ant的classpath中(windows-->preferences-->Ant-->runtime-->classpath) 
  
你完全可以不使用eclipse自带的ant,上面的步骤显得很麻烦,你完全可以开启dos窗口运行ant,但这样的话你就的两边切换窗口,一边在eclipse下写代码,一边在dos下运行ant,根据的自己的实际情况取舍吧 
  
2) 配置服务器 
我们主要通过tomcat manager api来完成部署工作,这个需要权限,所以你的修改 
$CATALINA_HOME/conf/tomcat-users.xml加入 
<user name="ant" password="secret" roles="manager" /> 
  
你可以通过手动访问下面的地址 
http:// localhost:8080/manager/html 
如果成功,说明你的服务端配置正确

<project basedir="." default="deploy" name="mac_web">
 <target name="init">
  <property name="Name" value="mac_web" />
  <property name="name" value="mac_web" />
  <property name="version" value="0.1" />
  <property name="year" value="2011" />

  <echo message="----------- ${Name} ${version} [${year}] ------------" />

  <property name="debug" value="off" />
  <property name="optimize" value="on" />
  <property name="deprecation" value="on" />

  <!--   java源文件路径 -->

  <property name="src.dir" value="${basedir}/src" />

  <!--   jar包路径 -->
  <property name="lib.dir" value="${basedir}/mac_web/WEB-INF/lib" />

  
  <!--   webapp路径 -->
  <property name="webapp.dir" value="${basedir}/WebContent" />
  <property name="packages" value="com.*.*.*" />

  <!--   准备源文件路径 -->
  <property name="build.src" value="${basedir}/AntBuild/build" />

  <!--   编译源文件路径 -->
  <property name="build.dest" value="${basedir}/AntBuild/bin" />

  <!--   准备webapp文件路径 -->
  <property name="buildwar.dest" value="${basedir}/AntBuild/warsrc" />

  <!--   准备javadoc文件路径 -->
  <property name="build.javadocs" value="${basedir}/AntBuild/doc" />

  <!--   打包jar文件路径 -->
  <property name="jar.dest" value="${basedir}/AntBuild/jar" />

  <!--   打包war文件路径 -->
  <property name="war.dest" value="${basedir}/AntBuild/war" />
 
  <!--   classpath -->
  <path id="classpath">
   <fileset dir="${lib.dir}">
    <include name="**/*.jar" />
   </fileset>
   <!--<pathelement location="lib/"/>-->
  </path>
  <filter token="year" value="${year}" />
  <filter token="version" value="${version}" />
  <filter token="date" value="${TODAY}" />
  <filter token="log" value="true" />
  <filter token="verbose" value="true" />

 </target>

 <!-- =================================================================== -->
 <!-- Help on usage -->
 <!-- =================================================================== -->
 <target name="usage" depends="init">
  <echo message="${Name} Build file" />
  <echo message="-------------------------------------------------------------" />
  <echo message="" />
  <echo message=" available targets are:" />
  <echo message="" />
  <echo message=" jar --> generates the ${name}.jar file" />
  <echo message=" build --> compiles the source code" />
  <echo message=" javadoc --> generates the API documentation" />
  <echo message=" clean --> cleans up the directory" />
  <echo message="" />
  <echo message=" Please rename build.properties.default to build.properties" />
  <echo message=" and edit build.properties to specify JSDK 2.3 classpath." />
  <echo message="" />
  <echo message=" See the comments inside the build.xml file for more details." />
  <echo message="-------------------------------------------------------------" />
  <echo message="" />
  <echo message="" />
 </target>

 <!-- =================================================================== -->
 <!-- 准备源文件-->
 <!-- =================================================================== -->
 <target name="prepare-src" depends="init">
  <!-- create directories -->
  <mkdir dir="${build.src}" />
  <mkdir dir="${build.dest}" />
  <mkdir dir="${jar.dest}" />
  <mkdir dir="${war.dest}" />
  <mkdir dir="${buildwar.dest}" />
  <!-- copy src files -->
  <copy todir="${build.src}">
   <fileset dir="${src.dir}" />
  </copy>
  <copy todir="${buildwar.dest}">
   <fileset dir="${webapp.dir}" />
  </copy>
 </target>

 <!-- =================================================================== -->
 <!-- 编译源文件-->
 <!-- =================================================================== -->
 <target name="build" depends="prepare-src">
  <javac srcdir="${build.src}" destdir="${buildwar.dest}/WEB-INF/classes" debug="${debug}" optimize="${optimize}">
   <classpath refid="classpath" />
  </javac>
  <copy todir="${buildwar.dest}/WEB-INF/classes">
   <fileset dir="${build.src}">
    <include name="**/*.xml" />
   </fileset>
  </copy>
 </target>

 <!-- =================================================================== -->
 <!-- 打war包-->
 <!-- =================================================================== -->

 <target name="mac_web.war" depends="build">
  <war warfile="${war.dest}/mac_web.war" webxml="${buildwar.dest}/WEB-INF/web.xml">
   <lib dir="${buildwar.dest}/WEB-INF/lib" />
   <classes dir="${buildwar.dest}/WEB-INF/classes" />
   <fileset dir="${buildwar.dest}">
   </fileset>
  </war>
  
 </target>

 <!-- =================================================================== -->
 <!-- 发布到本的resin和tomcat-->
 <!-- =================================================================== -->

 <target name="publish" depends="mac_web.war,clean">
  <copy todir="${tomcat.home}/webapps">
   <fileset dir="${war.dest}">
    <include name="**/*.war" />
   </fileset>
  </copy>
 </target>
 <!--
 <target name="SyncMain">
         <java classname="com.ce.synchronization.main.SyncMain" failοnerrοr="true" fork="yes">
             <classpath refid="classpath"/>
         </java>
 </target>
 -->
 <!-- =================================================================== -->
 <!-- 产生javadoc api 文档-->
 <!-- =================================================================== -->
 <target name="javadoc" depends="build">
  <mkdir dir="${build.javadocs}" />
  <javadoc packagenames="${packages}" sourcepath="${build.src}" destdir="${build.javadocs}" author="true" version="true" use="true" splitindex="true" windowtitle="${Name} API" doctitle="${Name}">
   <classpath refid="classpath" />
  </javadoc>
 </target>

 


 <!-- =================================================================== -->
 <!-- 清除临时文件-->
 <!-- =================================================================== -->
 <target name="clean" depends="init">
  <delete dir="${build.src}" />
  <delete dir="${build.dest}/org" />
  <delete dir="${build.dest}/com" />
  <delete dir="${buildwar.dest}" />
  <delete>
   <fileset dir="${build.dest}" includes="**/*.class" />
  </delete>
 </target>
  
 <!-- Configure the directory into which the web application is built -->
 <property name="build" value="${basedir}/webcontent/WEB-INF/classes" />
 <property name="dist.dir" value="${basedir}/dist" />
  
 <!-- Configure the context path for this application -->
 <property name="path" value="/mac_web" />
  
 <!-- Configure properties to access the Manager application -->
 <property name="url" value="http://192.168.100.209:8090/manager" />
 <property name="username" value="manager" />
 <property name="password" value="admin" />
  
 <!-- Configure the custom Ant tasks for the Manager application -->
 <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"/>
 <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"/>
  
  
 <target name="deploy" description="Install web application" depends="undeploy,mac_web.war,clean">
  <deploy url="${url}" username="${username}" password="${password}" path="${path}" war="${war.dest}/mac_web.war" />
 </target>
  
 <target name="deployonly" description="Install web application" depends="init">
  <deploy url="${url}" username="${username}" password="${password}" path="${path}" war="${war.dest}/mac_web.war" />
 </target>
  
 <target name="undeploy" description="Remove web application" depends="init">
 <undeploy url="${url}" username="${username}" password="${password}" path="${path}" />
 </target>

 

</project>



<project basedir="." default="deploy" name="mac_web">
 <target name="init">
  <property name="Name" value="mac_web" />
  <property name="name" value="mac_web" />
  <property name="version" value="0.1" />
  <property name="year" value="2011" />

  <echo message="----------- ${Name} ${version} [${year}] ------------" />

  <property name="debug" value="off" />
  <property name="optimize" value="on" />
  <property name="deprecation" value="on" />

  <!--   java源文件路径 -->

  <property name="src.dir" value="${basedir}/src" />

  <!--   jar包路径 -->
  <property name="lib.dir" value="${basedir}/mac_web/WEB-INF/lib" />

  
  <!--   webapp路径 -->
  <property name="webapp.dir" value="${basedir}/WebContent" />
  <property name="packages" value="com.*.*.*" />

  <!--   准备源文件路径 -->
  <property name="build.src" value="${basedir}/AntBuild/build" />

  <!--   编译源文件路径 -->
  <property name="build.dest" value="${basedir}/AntBuild/bin" />

  <!--   准备webapp文件路径 -->
  <property name="buildwar.dest" value="${basedir}/AntBuild/warsrc" />

  <!--   准备javadoc文件路径 -->
  <property name="build.javadocs" value="${basedir}/AntBuild/doc" />

  <!--   打包jar文件路径 -->
  <property name="jar.dest" value="${basedir}/AntBuild/jar" />

  <!--   打包war文件路径 -->
  <property name="war.dest" value="${basedir}/AntBuild/war" />
 
  <!--   classpath -->
  <path id="classpath">
   <fileset dir="${lib.dir}">
    <include name="**/*.jar" />
   </fileset>
   <!--<pathelement location="lib/"/>-->
  </path>
  <filter token="year" value="${year}" />
  <filter token="version" value="${version}" />
  <filter token="date" value="${TODAY}" />
  <filter token="log" value="true" />
  <filter token="verbose" value="true" />

 </target>

 <!-- =================================================================== -->
 <!-- Help on usage -->
 <!-- =================================================================== -->
 <target name="usage" depends="init">
  <echo message="${Name} Build file" />
  <echo message="-------------------------------------------------------------" />
  <echo message="" />
  <echo message=" available targets are:" />
  <echo message="" />
  <echo message=" jar --> generates the ${name}.jar file" />
  <echo message=" build --> compiles the source code" />
  <echo message=" javadoc --> generates the API documentation" />
  <echo message=" clean --> cleans up the directory" />
  <echo message="" />
  <echo message=" Please rename build.properties.default to build.properties" />
  <echo message=" and edit build.properties to specify JSDK 2.3 classpath." />
  <echo message="" />
  <echo message=" See the comments inside the build.xml file for more details." />
  <echo message="-------------------------------------------------------------" />
  <echo message="" />
  <echo message="" />
 </target>

 <!-- =================================================================== -->
 <!-- 准备源文件-->
 <!-- =================================================================== -->
 <target name="prepare-src" depends="init">
  <!-- create directories -->
  <mkdir dir="${build.src}" />
  <mkdir dir="${build.dest}" />
  <mkdir dir="${jar.dest}" />
  <mkdir dir="${war.dest}" />
  <mkdir dir="${buildwar.dest}" />
  <!-- copy src files -->
  <copy todir="${build.src}">
   <fileset dir="${src.dir}" />
  </copy>
  <copy todir="${buildwar.dest}">
   <fileset dir="${webapp.dir}" />
  </copy>
 </target>

 <!-- =================================================================== -->
 <!-- 编译源文件-->
 <!-- =================================================================== -->
 <target name="build" depends="prepare-src">
  <javac srcdir="${build.src}" destdir="${buildwar.dest}/WEB-INF/classes" debug="${debug}" optimize="${optimize}">
   <classpath refid="classpath" />
  </javac>
  <copy todir="${buildwar.dest}/WEB-INF/classes">
   <fileset dir="${build.src}">
    <include name="**/*.xml" />
   </fileset>
  </copy>
 </target>

 <!-- =================================================================== -->
 <!-- 打war包-->
 <!-- =================================================================== -->

 <target name="mac_web.war" depends="build">
  <war warfile="${war.dest}/mac_web.war" webxml="${buildwar.dest}/WEB-INF/web.xml">
   <lib dir="${buildwar.dest}/WEB-INF/lib" />
   <classes dir="${buildwar.dest}/WEB-INF/classes" />
   <fileset dir="${buildwar.dest}">
   </fileset>
  </war>
  
 </target>

 <!-- =================================================================== -->
 <!-- 发布到本的resin和tomcat-->
 <!-- =================================================================== -->

 <target name="publish" depends="mac_web.war,clean">
  <copy todir="${tomcat.home}/webapps">
   <fileset dir="${war.dest}">
    <include name="**/*.war" />
   </fileset>
  </copy>
 </target>
 <!--
 <target name="SyncMain">
         <java classname="com.ce.synchronization.main.SyncMain" failοnerrοr="true" fork="yes">
             <classpath refid="classpath"/>
         </java>
 </target>
 -->
 <!-- =================================================================== -->
 <!-- 产生javadoc api 文档-->
 <!-- =================================================================== -->
 <target name="javadoc" depends="build">
  <mkdir dir="${build.javadocs}" />
  <javadoc packagenames="${packages}" sourcepath="${build.src}" destdir="${build.javadocs}" author="true" version="true" use="true" splitindex="true" windowtitle="${Name} API" doctitle="${Name}">
   <classpath refid="classpath" />
  </javadoc>
 </target>

 


 <!-- =================================================================== -->
 <!-- 清除临时文件-->
 <!-- =================================================================== -->
 <target name="clean" depends="init">
  <delete dir="${build.src}" />
  <delete dir="${build.dest}/org" />
  <delete dir="${build.dest}/com" />
  <delete dir="${buildwar.dest}" />
  <delete>
   <fileset dir="${build.dest}" includes="**/*.class" />
  </delete>
 </target>
  
 <!-- Configure the directory into which the web application is built -->
 <property name="build" value="${basedir}/webcontent/WEB-INF/classes" />
 <property name="dist.dir" value="${basedir}/dist" />
  
 <!-- Configure the context path for this application -->
 <property name="path" value="/mac_web" />
  
 <!-- Configure properties to access the Manager application -->
 <property name="url" value="http://192.168.100.209:8090/manager" />
 <property name="username" value="manager" />
 <property name="password" value="admin" />
  
 <!-- Configure the custom Ant tasks for the Manager application -->
 <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"/>
 <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"/>
  
  
 <target name="deploy" description="Install web application" depends="undeploy,mac_web.war,clean">
  <deploy url="${url}" username="${username}" password="${password}" path="${path}" war="${war.dest}/mac_web.war" />
 </target>
  
 <target name="deployonly" description="Install web application" depends="init">
  <deploy url="${url}" username="${username}" password="${password}" path="${path}" war="${war.dest}/mac_web.war" />
 </target>
  
 <target name="undeploy" description="Remove web application" depends="init">
 <undeploy url="${url}" username="${username}" password="${password}" path="${path}" />
 </target>

 

</project>



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值