`
happyforever82
  • 浏览: 122465 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

ant checkout svn. 并ftp上传 运行远程命令

    博客分类:
  • java
阅读更多

<project basedir="." default="deploy" name="****">

 <property name="basePath" value="****" />
 <property name="destPath" value="${basePath}\svn" />

 <property name="svnurl" value="****" />
 <property name="svn.username" value="****" />
 <property name="svn.password" value="****" />

 <property name="server" value="****" />
 <property name="tomcat.path" value="****" />
 <property name="ftp.username" value="****" />
 <property name="ftp.password" value="****" />
 <property name="telnet.username" value="****" />
 <property name="telnet.password" value="****" />
 <property name="telnet.prompt" value="$" />

 <path id="ywtcclibpath">
  <fileset dir="${destPath}/global-lib">
   <include name="**\**.jar" />
  </fileset>
 </path>

 <taskdef name="svn" classname="org.tigris.subversion.svnant.SvnTask" />
 <target name="svncheckout" >
  <echo message="svn checkout from ${svnurl}" />
  <svn javahl="true" username="${svn.username}" password="${svn.password}">   
   <checkout url="${svnurl}/global-lib" destPath="${destPath}/global-lib" />   
   <checkout url="${svnurl}/****service" destPath="${destPath}/****service" />
   <checkout url="${svnurl}/****web" destPath="${destPath}/****web" />
  </svn>
 </target>
 
 <target name="preparewar" depends="svncheckout">
  <echo message="start to make a war" />
  
  <delete dir="${basePath}\target\web" />
  <mkdir dir="${basePath}\target\web" />

  <copy todir="${basePath}\target\web">
   <fileset dir="${destPath}\****web\web">
    <include name="**/**/**" />
    <exclude name="**/.svn/**" />
   </fileset>
  </copy>
  
  <mkdir dir="${basePath}\target\web\WEB-INF\classes" />

  <echo message="compile the service code" />
  <javac fork="true" classpathref="ywtcclibpath" srcdir="${destPath}\****service\src\main\java" encoding="UTF-8"
   destdir="${basePath}\target\web\WEB-INF\classes" target="1.5" memorymaximumsize="256m" excludes="**/.svn/**" />
  <copy todir="${basePath}\target\web\WEB-INF\classes">
   <fileset dir="${destPath}\****service\src\main\resource" />
  </copy>

  <!--
  <echo message="compile the service junit code" />
  <javac fork="true" classpathref="ywtcclibpath" srcdir="${destPath}\****service\src\test\java" encoding="UTF-8" destdir="${destPath}\target\web\WEB-INF\classes" target="1.5" memorymaximumsize="256m" excludes="**/.svn/**" />

  <junit showoutput="true" printsummary="true" fork="true">
   <classpath>
    <path>
     <fileset dir="${destPath}/target/lib">
      <include name="**\**.jar" /> 
     </fileset>
    </path>
    <path location="${destPath}\target\web\WEB-INF\classes" />
   </classpath>
   <formatter type="plain" />
   <batchtest haltonerror="on" haltonfailure="on" todir="${destPath}\target">
    <fileset dir="${destPath}\target\web\WEB-INF\classes">
     <include name="**\*Test.class" />
    </fileset>
   </batchtest>
  </junit>
  -->
  
  <echo message="compile the web code" />
  <javac fork="true" classpathref="ywtcclibpath" srcdir="${destPath}\****web\src\main\java" encoding="UTF-8" destdir="${basePath}\target\web\WEB-INF\classes" target="1.5" memorymaximumsize="256m" excludes="**/.svn/**" />
  <copy todir="${basePath}\target\web\WEB-INF\classes">
   <fileset dir="${destPath}\****web\src\main\resource" />
  </copy>
  <copy todir="${basePath}\target\web\WEB-INF\lib">
   <fileset dir="${basePath}\target\lib" />
  </copy>

  <war destfile="${basePath}\ROOT.war" basedir="${basePath}\target\web" />

 </target>

 <target name="shutdownAndUpload" depends="preparewar">

  <echo message="cleaning remote server files" />
  <telnet server="${server}">
   <read>login:</read>
   <write string="${telnet.username}" />
   <read>Password:</read>
   <write string="${telnet.password}" />
   <read string="${telnet.prompt}" />
   <write>${tomcat.path}/bin/shutdown.sh</write>
   <read string="${telnet.prompt}" />
  </telnet>

  <telnet server="${server}">
   <read>login:</read>
   <write string="${telnet.username}" />
   <read>Password:</read>
   <write string="${telnet.password}" />
   <read string="${telnet.prompt}" />
   <write>rm -R ${tomcat.path}/webapps/ROOT</write>
   <read string="${telnet.prompt}" />
   <write>rm -R ${tomcat.path}/webapps/ROOT.war</write>
   <read string="${telnet.prompt}" />
  </telnet>

  <ftp password="${ftp.password}" server="${server}" userid="${ftp.username}" remotedir="${tomcat.path}/webapps/" binary="true">
   <fileset file="${basePath}\ROOT.war" />
  </ftp>

 </target>

 <target name="deploy" depends="shutdownAndUpload">

  <telnet server="${server}">
   <read>login:</read>
   <write string="${telnet.username}" />
   <read>Password:</read>
   <write string="${telnet.password}" />
   <read string="${telnet.prompt}" />
   <write string="nohup ${tomcat.path}/bin/startup.sh" />
   <read string="${telnet.prompt}" />
  </telnet>
  <echo message="well doen, it's over." />

 </target>
</project>

1
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics