View RSS Feed

Eclipse

Working with SVN in Eclipse

Rate this Entry
by , 02-29-2012 at 12:26 PM (14312 Views)
In a team work environment, using a version control system has been becoming standard approach to foster collaboration among team members, increase productivity, centralize resources management, reduce risks and development time…Subversion (SVN) is a version control system which is very popular and widely used in software development, and Subclipse is an Eclipse plug-in that supports Subversion within the Eclipses IDE. Subclipse has been widely used to develop Java projects in Eclipse IDE for team-oriented working environments.

This article will walk you from installing to using Subclipse for the most common tasks in terms of team collaboration. The version of Eclipse IDE targeted in this article is 3.7 – Indigo for Java EE developers.

A brief overview about Subclipse

Subclipse is an open-source Eclipse plug-in that supports working with Subversion servers within Eclipse IDE. It allows many developers working together on a project at the same time and synchronizing their work through a set of perspectives, views and functionalities. The project is managed by CollabNet, Inc – the firm started to develop Subversion as a replacement for CVS. Its home page can be touch at: http://subclipse.tigris.org/. The latest version is 1.8.5 and it is working with Eclipse versions from 3.2 or higher. Subclipse can be installed from its update site via Eclipse’s Install New Software feature, or can be downloaded separately from its website to be installed locally.


Install Subclipse in Eclipse

The easiest way is to install Subclipse from its update site. Select Help -> Install New Software… from Eclipse’s main menu. In the Install dialog, type the following URL into the text field Work with:

http://subclipse.tigris.org/update_1.8.x

Hit Enter, Eclipse will load features available for the plug-in in the drop-down list, the Subclipse and SVNKit, as shown in the following screenshot:

Name:  install 1.png
Views: 5747
Size:  57.4 KB
Figure: Select features of Subclipse to be installed

Click Select All, and click Next. It may take a while for Eclipse to calculate requirements and dependencies before displaying the Install Details dialog:

Name:  install 2.png
Views: 5686
Size:  62.0 KB
Figure: Review the items to be installed

Click Next, in the Review Licenses screen, select I accept the terms of the license agreements:

Name:  review license.png
Views: 5681
Size:  63.9 KB
Figure: Accept the terms of the license agreements

Click Finish, Eclipse is installing the software:

Name:  installing software.png
Views: 5621
Size:  26.4 KB
Figure: Installation is in progress

During the installation, a security warning pops up:

Name:  security warning.png
Views: 5614
Size:  31.1 KB
Figure: Accept a security warning

Click OK. After installation completed, Eclipse asks to restart the IDE or apply changes immediately:

Name:  asks restart.png
Views: 5598
Size:  22.8 KB
Figure: Restart the IDE after installation completed

It is advisable to click Restart Now.


Perspectives and Views for SVN

Once installed, Subclipse provides two perspectives, one for SVN and one for team collaboration:

  • SVN Repositories Exploring
  • Team Synchronizing



You can switch to the perspective by select Window -> Open Perspective… -> Other, and select one from the Open Perspective dialog:

Name:  open perspective.png
Views: 5604
Size:  31.1 KB
Figure: Open perspectives provivded by Subclipse

The views provided by Subclipse can be found by selecting Window -> Show View -> Other… Expand the SVN branch:

Name:  show view.png
Views: 5631
Size:  26.4 KB
Figure: Views provided by Subclipse


Check in a project to a SVN server

Check in is the process of putting a project from a local computer to a SVN server. The project will be shared to other developers so that they can work on the project at the same time.

Right click on to the project in Project Explorer view, and select Team -> Share Project… from the context menu:

Name:  share project.png
Views: 5605
Size:  36.0 KB
Figure: Check in a project

The Share Project dialog appears, select SVN, click Next:

Name:  share project dialog 1.png
Views: 5603
Size:  28.4 KB
Figure: Select SVN as repository type

In the next screen, Share Project with SVN Repository, select Create a new repository location, click Next:

Name:  share project dialog 2.png
Views: 5589
Size:  34.2 KB
Figure: Create a new repository location

Type URL of the SVN repository into the Url field:

Name:  share project dialog 3.png
Views: 5616
Size:  29.4 KB
Figure: Type URL of the repository

Click Next, in the next screen, you can specify the name of the folder in the SVN repository:

Name:  share project dialog 4.png
Views: 5610
Size:  30.3 KB
Figure: Enter folder name

Click Finish. Note that you may have to enter user name and password to access the SVN repository, depending on the server’s settings.


Check out a project from a SVN server

Check out is the process of getting a project from a SVN server’s repository to local disk. There are two ways to check out a project in Eclipse:

  • Check out from menu File.
  • Check out from SVN Repositories view.



Check out from menu File

Select File -> New -> Project… In the New Project dialog, expand SVN node and select Check out projects from SVN:

Name:  check out 1.png
Views: 5586
Size:  42.8 KB
Figure: Create a new project from SVN

Click Next, in the next screen, select Create a new repository location:

Name:  check out 2.png
Views: 5559
Size:  36.2 KB
Figure: Create a new repository location

Click Next, enter URL of the SVN repository into the Url field, and click Next:

Name:  check out 3.png
Views: 5548
Size:  27.7 KB
Figure: Specify URL of the repository

Eclipse will load content of the repository on the SVN server and ask you to select a project folder:

Name:  check out 4.png
Views: 5550
Size:  30.5 KB
Figure: Select folder to be checked out

Click Next, in the Check Out As screen, you can specify how to check out the project as a new project using the New Project Wizard or as a project in the current workspace. You can also select to check out a specific revision. Click Finish when done:

Name:  check out 5.png
Views: 5543
Size:  40.6 KB
Figure: Check out options

The check out is in progress:

Name:  check out in progress.png
Views: 5551
Size:  29.5 KB
Figure: Eclipse is downloading project from SVN

Note that you may be asked for providing user name and password to access the SVN repository.


Check out from SVN Repositories view

Switch to SVN Repository Exploring perspective, in the view SVN Repositories, click on the Add Repository icon:

Name:  add svn repo.png
Views: 5507
Size:  9.0 KB
Figure: Add SVN repository

In the dialog Add SVN Repository, type URL of the SVN repository into Url field, and click Finish:

Name:  add svn repo 2.png
Views: 5549
Size:  27.4 KB
Figure: Specify URL of the repository

You may have to provide user name and password to access the SVN repository. Eclipse will load content of the repository in a hierarchical tree. Expand the repository node, and right click on the folder name which you want to check out:

Name:  check out context menu.png
Views: 5522
Size:  18.0 KB
Figure: Check out from context menu

And follow the steps same as described above, for the Check Out As screen.


Team collaboration tasks

Subclipse provides a comprehensive context menu for team collaboration, it is the Team menu which can be found in the context menu:

Name:  team menu.png
Views: 5539
Size:  69.3 KB
Figure: Team context menu


Synchronize with Repository

This task allows reviewing your changes with other team members in order to synchronize them. Select Team -> Synchronize with Repository from context menu, Eclipse will switch you to Team Synchronizing perspective:

Name:  team synchronize view.png
Views: 6431
Size:  154.9 KB
Figure: The Synchronize view

In the Synchronize view you can take a look at:

  • Outgoing changes: changes made by you and ready to be committed. They are denoted by an outgoing arrow in gray.
  • Incoming changes: changes made by other team members and ready to be updated. They are denoted by an incoming arrow in blue.
  • Conflicts: are the resources that have been changed by someone while you are still working on them. Conflicts are denoted by a two-way arrow in red.




From the changes in the Synchronize view, you can decide to do by some quick commands in the context menu:

Name:  quick commands.png
Views: 5490
Size:  24.1 KB
Figure: Quick commands in context menu

Commit
Push your changes to SVN repository. The dialog Commit appears, you can review what changes to commit and provide a comment, then click OK.


Update
Update the resource with a latest revision from the repository. A conflict will be notified if any.


Override and Update
Always replace the content of the resource with a latest revision from the repository. If there is any conflict, you’re the local version is overridden by the revision from the repository.


Mark as Merged
This command should be called to indicate that the current resource is merged with incoming changes from the repository. This is usually used after resolving conflicts.


Revert changes
Undo the changes made to the resource since the last update.


Show History
Review revision history of a resource. Details will be shown up in the History view, and you can switch back to a specific revision via context menu.


Above are the most frequently used tasks. There are many other tasks which are waiting for you to explore.

The Synchronize view comes with a handy toolbar that helps switching to incoming mode, outgoing mode, conflicts mode, update all incoming/outgoing changes…:

Name:  toolbar.png
Views: 5469
Size:  10.0 KB
Figure: Quick toolbar in Synchronize view

The Team Synchronization perspective also provides a very useful compare editor which lets you to compare the local changes and remote changes visually:

Name:  compare editor.png
Views: 5611
Size:  61.6 KB
Figure: Code compare editor


The compare editor is automatically loaded when double clicking on a resource, it is very helpful for resolving conflicts and merging changes.


Conclusion

Subclipse is a great plug-in for working with SVN and fostering team collaboration, so it should be one of must-have tools for any Java developers.

Submit "Working with SVN in Eclipse" to Facebook Submit "Working with SVN in Eclipse" to Digg Submit "Working with SVN in Eclipse" to del.icio.us Submit "Working with SVN in Eclipse" to StumbleUpon Submit "Working with SVN in Eclipse" to Google

Comments