Sunday 24 September 2017

ANT : SVN checkout

Steps on how to setup and checkout SVN code using Ant

1. Create a folder AntCheckout
2. Inside it create a folder lib
3. Download the below list of jars and place them in the lib folder




4. Inside Ant folder create build.properties file which should look like below:

svn.url=http://svn.test.com/svn/repos/myproject
svn.revision=HEAD
svn.uname=test

svn.password=test
svn.checkout.dir=myrepo

5. Update the property values accordingly with your SVN details.

6. Inside Ant folder create build.xml which should look like below:

<?xml version="1.0" encoding="iso-8859-1"?>
<project name="svncheckout" default="checkout">

    <!-- Antcontrib path -->
    <path id="antcontrib.path">
      <pathelement path="lib/ant-contrib-1.0b3.jar" />
    </path>
    <taskdef classpathref="antcontrib.path" resource="net/sf/antcontrib/antcontrib.properties"/>
    <taskdef classpathref="antcontrib.path" resource="net/sf/antcontrib/antlib.xml"/>
   
    <!-- SVNANT path -->
    <path id="svn.ant.classpath">
        <fileset dir="lib">
        <include name="**/*.jar"/>
        </fileset>
    </path>      
    <taskdef classpathref="svn.ant.classpath" resource="org/tigris/subversion/svnant/svnantlib.xml"/>

    <!-- SVN Checkout -->
    <svnSetting svnkit="true" javahl="false"  id="svn.settings"/>
    <target name="checkout" description="Pulls code from Subversion into the directory" depends="init">
            <echo>SVN URL: ${svn.url}</echo>
            <echo>Revision: ${svn.revision}</echo>
            <echo>Target Dir: ${svn.checkout.dir}</echo>
            <svn refid="svn.settings" username="${svn.uname}" password="${svn.password}" >
              <checkout url="${svn.url}" destPath="${basedir}/${svn.checkout.dir}" revision="${svn.revision}"/>
            </svn>  

             <!-- Remove unwanted .svn folders --> 
            <delete includeEmptyDirs="true">
                <fileset dir="${svn.checkout.dir}" includes="**/.svn/" defaultexcludes="false"/>
            </delete>
    </target>

    <!-- Clean folder before checkout -->
    <target name="init">
    <echo>Cleaning checkout folder: svn</echo>
        <delete includeemptydirs="true">
            <fileset dir="svn" includes="**/*"/>
        </delete>
        <mkdir dir="${svn.checkout.dir}"/>
    </target>
</project>

     <!-- Check if build.properties is available -->
    <available file="build.properties" property="file.exists" value="true" />
    <fail unless="file.exists" message="ERROR: Filename 'build.properties' does not exist." />
    <property file="build.properties"/>
 

7. Save All
8. Open command-prompt/ putty and set your ANT HOME
9. Run command ant checkout
10. The required artifacts will be checked-out in the myrepo folder.


Helpful? Please Comment.

Happy Learning!!

No comments:

Post a Comment

OSB 12c : Dynamic Routing to Business/Proxy Service

Dynamic routing is a kind of  Content-based Routing pattern, which is used when the BusinessService/ProxyService path is required to be de...