<!-- 部署tomcat application -->
<target name="deploy"  description="Install application in Tomcat">
      <deploy url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/CarManage" war="file:CarManage.war" />
</target>连续执行两次deploy,第二次会出错,问:在deploy之前如何判断项目已经部署?
<!-- 卸载tomcat application  --> 
<target name="undeploy" description="Remove application in Tomcat">
<undeploy url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" 
/>
</target>同样连续执行两次undeploy,第二次会出错,问:在undeploy之前如何判断项目已经部署?

解决方案 »

  1.   

    通过ssh,telnet可以解决:
    <target name="telnet" description="telnet remote start tomcat">
    <telnet userid="root" password="*****" server="192.168.1.102" port="23" initialCR="yes" timeout="50">
    <read timeout="30">*</read>
    <write>/usr/tomcat/bin/shutdown.sh</write>
    </telnet>
    </target>
    <target name="ssh-shutdown" description="sshexec">
        <sshexec host="192.168.2.4" username="root" password="*****"
          port="22" trust="true" command="/usr/tomcat/bin/shutdown.sh"/>
    </target> <target name="ssh-startup" description="sshexec">
        <sshexec host="192.168.2.4" username="root" password="dvision"
          port="22" trust="true" command="/usr/tomcat/bin/startup.sh"/>
    </target> 
      

  2.   

    <target name="ssh-shutdown" description="sshexec">
      <sshexec host="192.168.2.4" username="root" password="*****"
      port="22" trust="true" command="/usr/tomcat/bin/shutdown.sh"/>
    </target>  <target name="ssh-startup" description="sshexec">
      <sshexec host="192.168.2.4" username="root" password="dvision"
      port="22" trust="true" command="/usr/tomcat/bin/startup.sh"/>
    </target>