From the very beginning, Eclipse has been tightly integrated with Concurrent Versions System (CVS) to provide access permissions with change management capabilities. Currently, many projects (especially those running on the Apache Software Foundation) are using another change management system: Subversion. This article describes how to use Eclipse for projects that use the Subversion repository.
The original Eclipse installation has integrated support for CVS (a popular open source code change management system. The functions and limitations of CVS are well known, but many groups have been studying systems controlled by other versions, in order to provide better scalability, better support for merged changes and branch versions, and better support for binary file formats.
Subversion (SVN) is the most popular alternative to CVS. It provides better performance (allows intelligent local cache and database backend) and a fast and easy branching) and responses to all the problems that are frequently seen when using CVS.
Continue to read this article to learn how to add Subversion support to Eclipse and how to execute basic version control activities through IDE.
Before getting started
To learn more about this article, you need to download and install Eclipse (see references ). Download the Eclipse SDK package for your Platform to provide you with the basic Eclipse IDE (also known as Eclipse Platform) and Java Development Kit. If you plan to use C/C ++ (I am planning to do this), visit C Development Tooling (CDT) web site and use the update manager to install CDT (the next section describes how to use the update manager ).
You also need to access the Subversion repository. If you need to create a Subversion repository, you can find some excellent references on the Subversion Web site (see references. For demonstration purposes, I will show you how to check out the Subclipse project and use the project in the repository on the LAN.
Add Subclipse to Eclipse
Subclipse is a project that adds Subversion support for Eclipse IDE. We will use the Eclipse update manager to add Subclipse to Eclipse IDE. In Eclipse, selectSoftware Updates> Find and InstallOpen the update manager.
Figure 1. Eclipse update Manager
In addition to using this update manager to find software updates, we can also use this update manager to find and install new features, such as Subclipse. Be sure to selectSearch for new features to installAnd then clickNextTo continue. Eclipse displays the next panel of the update manager.
Figure 2. Update the manager site
Because we need specific features, deselect the existing site and clickNew Remote SiteTo display the New Update Site dialog box (see figure 3 ). We will use this dialog box to add the Subclipse Update site to the list.
Figure 3. Add a new update site
Enter the content you need in Name (Subclipse
Is the best choice), and enter the following URL:http://subclipse.tigris.org/update_1.0.x
(The current Subclipse Update site ). ClickOKAdd the Subclipse Update site to the update Manager List.
In the update manager window, clickFinishTo start searching for new features. In this example, the new feature we need is Subclipse. A moment later, the update manager search is complete and the search result is displayed.
Figure 4. New features that can be installed
Select Subclipse (you can click the triangle symbol to view details of this feature), and then clickNextView the license terms for this feature. Accept the terms and then clickNextCheck the features you selected for installation. ClickFinishDownload and install Subclipse.
The update manager downloads the Subversion component. Before installing any content, Eclipse will notify you that this feature does not have a digital signature (figure 5 ). This is your last chance to cancel the installation. ClickInstall AllContinue to install.
Figure 5. Subclipse no Digital Signature
After the Subversion is installed, Eclipse immediately notifies you that you may need to restart the IDE to activate the new feature (see figure 6 ). To be considerate, restart Eclipse.
Figure 6. Restart Eclipse after installing new features
After you back up Eclipse, you can install and use Subclipse smoothly.
If you are running Eclipse on Mac OS X or Linux, you may need to install the JavaHL library. The Library is described in the Troubleshooting section in the Subclipse FAQ (see references ). Make these preparations before continuing to use Subclipse.
Quick Test
After the installation is complete, new features are always pleasant to test. We will check a copy of Subclipse from the Subversion repository to ensure that it is correctly installed.
SelectImportOpen the Import Manager (see figure 7 ). SelectCheckout ProjectsFrom SVN, and then clickNext.
Figure 7. Import Manager
In the Select/Create Location panel (see figure 8), we need to Create a new Location (because no configuration has been made), so clickNextContinue. IfNextThe button is disabled. SwitchUse existing repository locationAnd then returnCreate a new repository locationTo enableNextButton.
Figure 8. Create a repository
In the following section (see figure 9 (http://subclipse.tigris.org/svn/subclipse/
), And then clickNext. A moment later, Eclipse prompts you to enter the user ID and password. If you do not have an account on the Subclipse site, enterguest
As the user ID, enter a space as the password, and selectSave PasswordBox, and clickOK.
Figure 9. Add repository URL
Eclipse displays the folders in the Subclipse repository (see figure 10 ). Expand trunk, select the subclipse folder, and then clickFinishYou can check out a copy of the source code of your own Subclipse project. Because you do not have any idea about this, selectSimple> Project.
Figure 10. Subclipse Repository
Basic Subversion operations
Now we have successfully installed Subclipse and added support for the Subversion server in Eclipse settings. By downloading the latest Subclipse source code from the repository, we have tested Subclipse. Now we should consider using our own code and the Subversion repository to do something.
Before presenting How to Use Subversion, I would like to briefly introduce my repository. It resides on a machine called dogma and port 8000. I created a developerWorks repository for Code related to my developerworks article. I placed the project directly in the root directory of the repository. The trunk, tags, and branches folders under the root directories of other repositories are used to store development versions, labels, and branches respectively. But I don't want to worry about the label and branch operations of the Code in the developerWorks article.
I have added two projects, forkWork and threadWork, from my first developerWorks article. My Eclipse workspace (see figure 11) also contains three other projects from the developerWorks article (getopt_demo, getopt_long_demo, and readdir_demo ).
Figure 11. My Eclipse C/C ++ Projects
Now, we have made all preparations and can start our work.
Add a project to the repository
To add a new project to the Subversion repository, right-click the project (in any Eclipse project view or Navigator view) and selectTeam> Share Project. The Share Project dialog box is displayed in Eclipse.
Figure 12. Share Project dialog box
Select SVN from the list of repositories currently supported by Eclipse, and then clickNext. The following dialog box (see figure 13) allows you to select an existing repository location or create a new location.
Figure 13. Select the repository location
If your repository has been listed (as you can see, I have added your own repository), select it, and clickFinish. If your repository is not listed, add it (for instructions, see quick test) and continue. Eclipse creates a directory in the repository with the same name as the project and displays a list of all files and folders in the project.
Figure 14. Add PROJECT CONTENT
Enter the appropriate content in the field at the top to describe the project, and then clickSelect AllSelect all files of the project. ClickOKTo check the project and pass its current status to the Subversion repository.
Subversion commands and output results are displayed in the Console view, usually at the bottom of the Eclipse window (if you see what Subclipse has performed on the project ).
Update a project
One of the important features of the version control system is that other developers can continue development at any time and submit their changes when preparing. To download these changes and integrate them with local copies, you need to update the project.
Right-click the project you want to update and selectTeam> Update. Eclipse will retrieve any changes from the repository and try to merge them with the local copy.
Add a file or directory
If you add a file to a project (see Figure 15), it does not automatically become part of Version Control-you need to explicitly add it to a specific repository. In the screenshot below, you can see that I have added the ReadMe.txt file to the threadWork project.
Figure 15. Add a new file
Right-click the new file and selectTeam> Add to Version Control. That's it! The next time you submit the changes in this project to the repository, the new files will also be checked in.
Delete a file or directory
If you add a file to a repository that is not related to the project, you can easily delete it. Right-click the file and selectDelete. You do not need to use the Team menu. Subclipse automatically marks the file to be deleted and removes it from the project. The file is deleted when the change is submitted to the repository next time.
Rename a file or directory
To rename a Subclipse-controlled file or directory, right-click it and selectRename. In the input field, type the new name of the item, and pressEnterKey. The file is renamed in the project. The RENAME operation (adding a new name through the Add operation and deleting the old name through the Delete operation) waits for your next submission. In Figure 16, you can see the threadWork project after renaming main. c to threadWork. c and submitting the change. Note: The Blue plus sign added by Subclipse for the "new" file indicates that the file is scheduled to be added at the next submission.
Figure 16. renaming a file is an atomic operation, although it contains an add operation and a delete operation
Ignore files
If the project generates files or contains the Subversion repository files that you do not want to check in, you can notify Subclipse to ignore them. Right-click the file or directory you want to exclude from version control, and selectTeam> Add to svn: ignoreThe Add to svn: ignore dialog box is displayed.
Figure 17. Ignore resources not under Version Control
ClickOKAdd the specified file to the svn: ignore attribute of the project directory. SelectWildcard extensionIgnore all files with the current file extension, or selectCustom patternAdd your own wildcard in the ignore list. The changes to the ignored list will be added to the repository when the next change is submitted.
Submit changes
If you are satisfied with the changes to the project, confirm that your code can be compiled, and you have tested the changes, submit them to the Subversion repository. When your workstation crashes, it can act as a backup and allow other developers to update their local copies to include your changes.
Before submitting a change request, make sure your project is updated (see "Update Project "). Right-click the project and selectTeam> Commit. Eclipse displays a Commit dialog box (see figure 18), which summarizes your changes.
Figure 18. Submit the changes to the repository
If you observe carefully, you will see a property changed to the project directory (I have addedsvn:ignore
Properties to keep some files out of the Repository) and delete main. c when threadWork. c is added. This change actually represents an operation (File rename ).
If you want to keep some resources out of the repository, you can cancel the selection of these resources. This method is useful if you have completed some work in a file and do not want to check for unfinished changes. Enter the appropriate comment in the text field at the top, and then clickOKCheck the changes to the repository.
Conclusion
The Subclipse project integrates support for the Subversion version Version Control System with Eclipse's outstanding team project management functions (the latter only provides out-of-the-box support for the CVS server ). Using the Eclipse update manager, you can easily add Subclipse to your Eclipse installation. This allows you to directly use this advanced feature from Eclipse (at least I think so) version Control System.
Although adding a project to a repository-and managing your project resources (if any)-is a daunting task for users who are not familiar with Subversion, however, the process of common operations is very simple. This article describes the daily operations and helps you familiarize yourself with Subclipse.