Java Chatter and Random Nagging

Thursday, November 02, 2006

Getting started with Subversion (and Eclipse)

I recently followed a course on Configuration Management and after reading some random sources on the net, the topic really got me interested. So now it's time to put some of the techniques into practice, with one of my current pet-projects as laboratory mouse. Today I start off with a quick guide on Subversion and how to get it working with Eclipse.

I installed both the SVN server (in my case in subversion_server folder) and the repositories on my external hard-drive, all under the folder name subversion_projects.

Installing it all on the external drive allows me to make things a little more portable and also to test the configuration on another pc. In the ideal world, I would install it on a server pc, but this will do for now.

Steps to get it working:
  1. Download Subversion (the server) and Install in the ${svn} directory ( Subversion folder in my case).
  2. Test the Subversion install by running ${svn}\bin\svnadmin
  3. Create a repository on the machine that is going to host your source code.

    I am creating one repository having the name of the big project. This project is going to consist of four or five eclipse projects with dependencies among each other. Some people choose to have one repository for each eclipse project, but if your eclipse projects are quite dependent on each other, create one big repository. (More info about laying out your projects here)
    The structure will be


    From the command line on the server machine, standing in the : ${svn}\bin directory :
    svnadmin create drive:\${REPOSITORIES-DIR}\${projectname}
    } : the name of a folder that will contain all your Subversion source code repositories.
    ${projectname} : the name of the specific project you're going to create a repository for.
  4. Start the server from the command line:
    svnserve -d -r drive:\${REPOSITORIES-DIR}
  5. Within the drive:\${REPOSITORIES-DIR}\${projectname} directory, open the conf\svnserve.conf file using your text editor of choice and add the following to allow reading and writing to the users in the database we just created:

    anon-access = none
    auth-access = write
    password-db = passwd

  6. Stil in the conf directory, edit the passwd file and add user = password
    For example :

    ward = w4rd

  7. Start the server again from the command line:
    svnserve -d -r drive:\${
  8. Create the trunk, tags and branches directories :
    svn mkdir -m "directory creation" svn://localhost/hammock/trunk --username ward --password w4rd
    svn mkdir -m "directory creation" svn://localhost/hammock/tags --username ward --password w4rd
    svn mkdir -m "directory creation" svn://localhost/hammock/branches --username ward --password w4rd
  9. Install SubClipse as described here. In short, the installation can be initiated from within Eclipse's Software Install (Find and Install..) using as the remote site.
  10. I was already working on an existing pet-project. To add it under source-control, you fire up your eclipse afterwards. Than you click the existing project and choose Team : Share -> SVN and select all sources you are wanting to add under source control. Add the eclipse project under trunk/${eclipse-project-name}.
  11. For first use, you have to configure the repository first. Choose svn://localhost/${projectname} as URL of the repository and type your user and password as configured in step 6.
  12. More info for daily use of Subversion can be found here.
    For in-depth use of SVN, the ultimate reference is the free SVN book, but my use of Subversion for my pet-project is too basic to need such extended book at the moment.
Personally, I chose not to install Tortoise SVN client because I am currently not needing source control outside of my Eclipse workspace or command line. However, if you do need that, an easy install can be found here.

P.S. I am running Windows XP but I don't expect much differences in approach for another OS (except for the slashes of course).


Post a Comment

<< Home