ANT Tomcat 自动部署

Tomcat version: 6.0.18

 

添加下面内容到tomcat-user.xml中

 

<role rolename="manager"/>
<role rolename="admin"/>
<user username="admin" password="123456" roles="admin,manager"/>

 

添加 下面内容到context.xml中

<Context reloadable="true" antiResourceLocking="true" antiJARLocking="true">

 

 

 

build properties

 

#tomcat properties

tomcat.dir=D:/tools/javatool/apache-tomcat-6.0.20
tomcat.webapps=D:/tools/javatool/apache-tomcat-6.0.20/bin
tomcat.manager.url=http://localhost:8008/manager
tomcat.manager.username=admin
tomcat.manager.password=admin


#Jreport source
JRS.source=D:/cheping/Server/bin/distribute/xx.war

#context properties
JRS.context=xx

 

 

<?xml version="1.0"?>
<project name="autoBuild" default="deploy-application" basedir=".">
    <property file="build.properties"/>
    <path id="lib.path">
      <fileset dir="${tomcat.dir}" includes="lib/catalina-ant.jar"/>
      <fileset dir="${tomcat.dir}" includes="lib/*.jar"/>
     
  </path>
  <!-- Ant Tomcat Task Definition -->
    <typedef name="deploy"
             classname="org.apache.catalina.ant.DeployTask"
             classpathref="lib.path"
  />
    <typedef name="undeploy"
             classname="org.apache.catalina.ant.UndeployTask"
             classpathref="lib.path"
  />
 
  <typedef name="list" classname="org.apache.catalina.ant.ListTask"
        classpathref="lib.path"
   />
   
    <target name="deploy" description="Install application in Tomcat">
        <deploy url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${JRS.context}" localWar="file:${JRS.source}" />
    </target>

    <target name="undeploy" description="Remove application in Tomcat" if="already.deployed">
        <undeploy url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${JRS.context}" />
    </target>

    <target name="start" description="Start Tomcat application">
        <start url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${JRS.context}" />
    </target>

    <target name="stop" description="Stop Tomcat application">
        <stop url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${JRS.context}" />
    </target>

    <target name="list" description="List Tomcat applications">
        <list url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" />
    </target>

    <target name="deploy-application" description="Compile the web application...">
        <echo message="Undeploying the application only if it's deployed..." />
        <available file="${tomcat.webapps}/${JRS.context}" property="already.deployed" />
        <antcall target="undeploy" />

        <antcall target="deploy" />
        <antcall target="list" />
    </target>
</project>

 

你可能感兴趣的:(apache,tomcat,xml,Web,ant)