Thursday, August 27, 2009

Configuring common targets using svn externals with Tortoise subversion

Hi all,

Today I would like to share an advanced topic in subversion using Tortoise SVN (a windows application, for more info click here).

Before I begin,I would like to tell a real-time use case for which I used svn:externals. I am working on a JAVA which has more than 100 modules and these modules are dependencies for the main project.I have some targets which are very common to all 100 modules (e.g: ant clean, ant reports, some ivy tasks), for this as a general practice I have included common and uncommon targets in every module of build.xml (It means if I want to do any common change for 100 builds, i have to modify 100 builds individually, which is lot of pain, time consuming factor) Then my team lead (John Stotler ) has given an excellent idea of implementing “Externals” into subversion.

After doing some little research and an article written by Jesper in his blog, I got an idea of setting up subversion externals using Tortoise subversion.

This article is written totally in considering the above scenario, svn:externals can be used in many ways for information on multiple scenarios please refer the official document.

Here is the procedure for configuring svn externals for common targets.

  1. Identify the common targets which are common for all dependencies/modules.Like in my scenario i have more 5 common targets which are required in every module.Common targets in the sense the content which is defined inside the target should be same in all other dependencies:

    Example: 

    <target name="clean" description="cleans build directory within your project">

    <delete dir="${builddir}"/> 

    </target>

  2. Create new xml file say (commontargets.xml) and add all the identified common targets in to that file and create folder “commontarget” with tags and trunk as subfolder, further add commontargets.xml to trunk folder.
  3. Do svn commit so that the folder stores in respective svn repository,Lets say the svn repository url for commontarget is http://subversion.company/repositories/projects/project1/externals/commons/commontargets/trunk/
  4. Now open the project for which you want to add externals and right click on trunk and select “TortoiseSVN”>”Properties”
  5. A properties dialogue box opens and click on “New” and “add properties” dialogue box opens and from the top right drop down box select “svn:externals” and in the property value text box paste the commontargets svn repo url and click OK.
  6. Now open the project and do svn update, then your commontargets folder will in your project trunk folder.
  7. So do the same process of all projects which has a common targets and if you want to do any changes to common targets, just need to change commontargets.xml and commit the changes, that's it. every thing gonna be easy.

Let me know if you have any issues, I will try to answer.

--Kumar.

    No comments:

    Post a Comment