zoukankan      html  css  js  c++  java
  • Ant步步为营(3)在svn上checkout code.

    马上下班了,在发一篇吧。今天这个的时候发现好多好的网址,所以提前发了。

    老规矩:build.xml

    <?xml version="1.0"?>
        <project name="StartProduct" default="checkout.testcode" >
        <property file="build.properties"></property>

    <!--引入svn的jar包-->
            <path id="svnant.lib">
                    <fileset dir="${ant.libs}">
                        <include name="svnant.jar"/>
                        <include name="svnjavahl.jar"/>
                        <include name="svnClientAdapter.jar"/>
                        <include name="svnkit.jar"/>
                    </fileset>
                </path>
            <!-- 引用svn task文件,使用svn任务可以使用,下边这两个是jar里的文件-->  
            <typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="svnant.lib" />
            <taskdef resource="net/sf/antcontrib/antcontrib.properties">
                        <classpath>
                            <pathelement location="${ant.libs}/ant-contrib-0.6.jar"/>
                        </classpath>
                    </taskdef>
            <!--
            <target name="checkout.all" >
                    <if>
                        <and>
                          <not>
                            <equals arg1="SWTBot" arg2="SWTBot" />
                          </not>
                        </and>
                          <then>
                            <antcall target="checkout.testcode"></antcall>
                          </then>
                    </if>
                  </target>
                  -->
            <!--Target to checkout code of testing project from svn-->
                 <target name="checkout.testcode" if="true">
                     
                     <if>
                         <contains string="${svn.testcode.url}" substring="swtbot" />

                        <!--用正则表达式的方式找出要check的代码-->
                         <then>
                             <propertyregex property="dest.dir" input="${svn.testcode.url}" regexp=".*/([^/]*)/" select="1" override="true" global="true"/>
                         </then>
                         <else>
                             <propertyregex property="dest.dir" input="${svn.testcode.url}" regexp=".*/(branches)/(.*)/([^/]*)/" select="1_2_3" override="true" global="true"/>
                         </else>
                     </if>
                     <echo>testcode.dest=${svncode.dir}${dest.dir}</echo>

          <!-- 在本地目录下创建一个文件夹存放在svn上下载下来的code-->
                     <mkdir dir="${svncode.dir}${dest.dir}"/>
                   <!-- 清空本地文件夹下的内容-->
                     <delete dir="${svncode.dir}/${dest.dir}" quiet="true" />
                     <available file="${svncode.dir}${dest.dir}" type="dir" property="svn.present"/>
                              
                              <if>
                             <equals arg1="${svn.present}" arg2="true" />
                             <then>
                                 <svn  svnkit="true" username="${svn.username}" password="${svn.password}"  javahl="false" >        
                                      <cleanup dir="${svncode.dir}${dest.dir}"/>
                                 </svn>
                                 <svn  svnkit="true" username="${svn.username}" password="${svn.password}"  javahl="false" >        
                                     <update revision="HEAD" dir="${svncode.dir}${dest.dir}">
                                     </update>
                                 </svn>
                             </then>
                             <else>
                                 <svn  svnkit="true" username="${svn.username}" password="${svn.password}"  javahl="false" >
                                     <checkout url="${svn.testcode.url}" destPath="${svncode.dir}${dest.dir}" />
                                 </svn>
                             </else>
                           </if>    
                     
                </target>
        </project>

    build.properties文件内容:

    file.dir=G:\_files
    ant.libs=E:\New_SWTBot\swtBotWorkBenchBranch\org.talend.ant.demo\lib
    svn.testcode.url=https://**/svn/swtbot/
    svn.username=**
    svn.password=**
    svncode.dir=G:\_files

    > 要实现ant可以从svn服务器上检出代码要使用svnant jar,svnjavahl.jar,svnClientAdapter.jar,svnkit.jar文件。

    > 执行脚本后会在G:\_files下新建一个SWTBot文件夹,然后checkout code到这个文件夹下。

    > 几个好的连接网址:

    http://tianlihu.iteye.com/blog/741239

    http://enjoyyou.blog.hexun.com/41449457_d.html

    http://nneverwei.iteye.com/blog/679999

    http://hzl7652.iteye.com/blog/1188967

    http://hi.baidu.com/gg7663/item/970418469b3cd1e6bcf4516a

    http://ant.apache.org/manual/index.html

  • 相关阅读:
    习题10-2 递归求阶乘和(15 分)
    在过滤器中得到模型状态信息
    理解OAuth 2.0
    asp.net mvc 控制器的依赖注入(使用Ninject)
    web.routing 学习
    深度优先和广度优先的基础应用
    数的全排
    C# 表达式树
    C#中RSA的简单使用
    select into 和insert into select
  • 原文地址:https://www.cnblogs.com/QAZLIU/p/3699837.html
Copyright © 2011-2022 走看看