How To Configure Eclipse to Work with Subversion Using Subclipse

I use two different software/plugins for Subversion. TortoiseSVN is both a stand-alone software that is integrated with Windows Explorer, and also has an Eclipse plugin, and Subclipse which is another Eclipse plugin that can be installed/updated from within Eclipse by enterting this path for the Remote Site It is assumed in this procedure that you have installed all software needed.

Checking Out a project is how you download a working copy of your site files to your local hard drive. Once you have a working copy, you no longer have to check anything out. The working copy is associated with the repository on the Development Server - that is all that is required. There are a numerous ways to checkout a project, but in this article I will explain the procedure I use.

Using Eclipse and the Subclipse plug-in to Connect to Respositories and Checkout Projects

Switch to the SVN Repository Exploring perspective in Eclipse. Right click in the left pane, called SVN Respository. Select New>Respository Location.... It will ask for the URL to the respository. This is the format you will always use
svn://[serverName]:[portNumber]/[ProjectName]

Expand the respository after it loads, and you will typically see three directories: branches, tags, and trunk.

The trunk directory always holds the "working copy" of your project; which are the actual files you want to edit.

First you have to check them out, which is to say, copy them down to your local hard drive so you can work on them.

Right click on Trunk and select Checkout. This brings up a dialog box: Select the second radio button that says

Check out as a project in the workspace
Next to Project Name: you want that to be the name of the project - this will be the name of the folder in your webroot too. Click Next. Uncheck the checkbox that says
Use default workspace location
Enter the path to your webroot. My local path is C:\www (for Apache). Click Finish. Click over to the CFEclipse perspective now, and you will the Project and all of the files. If you check your webroot you will see the folder you named in there, and despite new icons for the folders and other Subversion specific indicators, those files are just like any other files in your webroot.

Using the Tortoise Eclipse Plug-in to Update and Commit Projects

First we must configure the Tortoise Plug-in for Eclipse. Window>Preferences...then click Tortoise from the menu on the left. There are 3 text fields:
  1. Path:
    C:/Program Files/TortoiseSVN/bin/TortoiseProc.exe
    NOTE: Slashes are reversed for display purposes.
  2. SVN Server:
    svn://[serverName]:[portNumber]
  3. Shared Root Folder: Leave Blank
Click OK to close Preferences.

In the CFEclipse Perspective, you can now right click on any file or folder to do an Update or Commit. Right-click, select Tortoise, then SVN Update or SVN Commit.

Remember to do an Update first, before you do a Commit.

An Update merges changes to the repository version with your copy, bringing your version up-to-date. A Commit then merges your changes to the repository copy, causing a new version to be created.

That's it. You're connected to the Respository, your CFEclipse project was automatically setup when you Checked out the files, and you can now Update and Commit your code changes to the repository in a variety of ways.

By the way, if something happens to your Eclipse and you are forced to re-install it; maybe you want to upgrade it. There's no need to reconnect to the Repository and Checkout the Files again. They'll still be in your webroot. If you have the Subclipse and CFEclipse plug-ins reinstalled, then simply create a new CFEclipse project, mapping to the files in your local webroot, and it will automatically re-connect to the repository. Your project contains an .svn folder that has all the info it needs, which is pretty handy.

Comments
Jim Priest's Gravatar Just curious - why don't you just use Subclipse for everything?? You can do everything you need (checkout, commit, update, etc) just using Subclipse...
# Posted By Jim Priest | 8/17/07 2:34 PM
Jim Pickering's Gravatar To be honest, I'm new with Subversion and have figured everything I know about it on my own. I tend to take the path of least resistance, which also means, highest efficiency. I did not know how to Commit or Update with Subclipse, and with the Tortoise plug-in installed, it was easier to figure out, so I used that.

Since you asked the question, I dove into the Subclipse docs and now understand that the menu items for it are in the Team menu. I guess I overlooked Team because I thought Eclipse's built-in CVS functionality used the Team menu.

I like TortoiseSVN in Windows Explorer. The Tortoise plug-in is weaker, but was intuitive. I will give Subclipse a chance to win me over. It might save some time in reinstalling two plug-ins everytime I upgrade Eclipse/Flex Builder.
# Posted By Jim Pickering | 8/17/07 2:51 PM
Jim Priest's Gravatar Yes - I use Tortoise as well when I'm doing things outside of Eclipse. FYI - the Tortoise help is VERY good for SVN stuff... I recommend taking some time to read it if you are new to SVN...

You can also setup some shortcut keys in Eclipse - I have CTRL+C = commit and CTRL+U = update so it's very quick to keep things in sync.
# Posted By Jim Priest | 8/17/07 4:03 PM
Copyright ©2007 JimPickering.com. Some rights reserved. BlogCFC was created by Raymond Camden. This blog is running version 5.1.004.