码迷,mamicode.com
首页 > 其他好文 > 详细

ant实例

时间:2017-12-14 23:54:00      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:cdir   执行   word   style   project   hex   rip   depends   实例   

<?xml version="1.0" encoding="UTF-8" ?> 
<project name="javaTest" default="sshexec8081" basedir="."> 
    <property name="server" value="192.168.0.112"/>
    <property name="user" value="root"/>
    <property name="password" value="root"/> 
    <property name="command" value="java -jar /home/shutong/helloworld.jar"/>     
  <target name="clean">     
  <delete dir="build"/>    
  </target>
  <target name="compile" depends="clean"> 
    <mkdir dir="build/classes"/>    
    <javac srcdir="src" destdir="build/classes"/>  
  </target>
  <target name="run" depends="compile">     
    <java classname="HelloWorld">         
    <classpath><pathelement path="build/classes"/></classpath>    
    </java>  
  </target>
  <target name="jar" depends="run"> 
  <jar destfile="helloworld.jar" basedir="build/classes">           
    <manifest>               
      <attribute name="Main-class" value="HelloWorld"/>      
    </manifest>       
  </jar>
  </target>
    <property name="name" value="amigo"/>
    <property name="age" value="25"/>
  <target name="sshexecdelete"  description="delete">
    <sshexec host="${server}"  
         username="${user}"  
         password="${password}"  
         port="22"  
         trust="true"  
         command="rm -rf /home/shutong/helloworld.jar"
         />  
         <echo message="删除目标jar包成功" />  
  </target>
  <target name="myscp" depends="jar,sshexecdelete">
    <scp file="./helloworld.jar" todir="${user}:${password}@${server}:/home/shutong/" trust="true"/>
    <echo message="连接上传${server}服务器成功" />  
  </target>  
  <target name="sshexec8081" depends="myscp" description="8081">
    <sshexec host="${server}"  
         username="${user}"  
         password="${password}"  
         port="22"  
         trust="true"  
         command="${command}"
         />  
         <echo message="程序执行成功" />  
  </target> 
</project>

 

ant实例

标签:cdir   执行   word   style   project   hex   rip   depends   实例   

原文地址:http://www.cnblogs.com/Jims2016/p/8040377.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!