Getting Eclipse in Sync with Subversion and Google Code
Two of the most popular open source projects for developers are the Eclipse development environment and the Subversion revision control system. Many developers use both tools on software they host at Google Code. You can tie all three together and seamlessly upload code by using Subclipse, an Eclipse plugin, to exchange files between your local environment and Google Code's Subversion repository.
If you want to see how this works but you don't already have a project hosted on Google Code, you can easily create a new project. Be sure to select Subversion as your version control system. Click on Create project, and your project will then be accessible from Google Code under the My Favorites link.
Presumably, if you've read this far, you already work with Eclipse, but if not you can visit the Eclipse Downloads page to find the software. I use Eclipse Classic, which works well with Subclipse. Extract the code from the tarball with the command
tar -zxvf eclipse-SDK-4.2-linux-gtk-x86_64.tar.gz, change to the new eclipse folder, and start the application with the command
./eclipse. When Eclipse starts, you can select a workspace in which to store your working Eclipse projects. The default, /home/user/workspace, is fine.
To install Subclipse, first click on the Help link in the top right corner of Eclipse, then click on Install New Software. In the resulting dialog box, enter into the "Works with" field
http://subclipse.tigris.org/update_1.8.x and click Add. When prompted for a name, use Subclipse, then click OK. In the center box, select the Subclipse option, then click Next, and Next again when the list of options to be installed appears. Eclipse will then install and set up Subclipse. After you restart Eclipse, Subclipse will be ready to use.
Connecting Subclipse to Google Code Project Hosting
The next step is to connect Subclipse to your Google Code project. Browse to your project page, click on the Source tab, and copy the SVN URL labeled for project members:
https://your_url.googlecode.com/svn/trunk, for example. Go back to Eclipse and click Window at the top of the application. Select Show View -> Other. Browse to SVN, then choose SVN Repositories and click OK. Right-click in the white space of the new SVN Repositories tab and choose New -> Repository Location. Paste in your URL and click Finish.
Now, once you have an Eclipse project ready, you can open it and upload it to Google Code hosting. Highlight the project you wish to work with, then go to Project -> Open Project. When the project is loaded, right-click on it and select Team -> Share Project. In the dialog box that appears, select SVN and click Next. You will be asked to select an SVN repository; select the URL you used previously, and click Next. Choose a folder name, or stick with the project title as the folder name, then click Finish.
You will be prompted to enter a username and password for the Google Code project hosting authentication, which is not the same authentication information you use for any other aspect of your Google account. Back on the Google Code project's Source page, look for the link labeled "googlecode.com password." Click it and write down the password generated. Then return to the open dialog in Eclipse and enter the information. Eclipse will resume uploading your project to Google Code. At some point during the process you will be prompted to Synchronize View, which lets you browse and track project history as changes and updates are made to your project.
Committing Your Project
At this point, if you were to browse to your Google Code project at something like http://code.google.com/p/Project_Name/source/checkout, you would notice that no code has been submitted yet. Even though you connected Subclipse to your Google Code project page, you haven't yet sent the project to the repository until you commit it. To do that, look for the Package Explorer on the left side of Eclipse. Right-click on it and select Team -> Commit. In the dialog box that appears, you can comment on the code you're ready to upload, and select how much of the project you wish to send; by default the entire project is selected. When the upload process is finished, you can visit your Google Code project to check your work. Click the Source tab, then Changes.
Once you've successfully uploaded a project to Google Code SVN repositories, you need to make sure that people can check out your code. With Eclipse open, locate the project SVN repository in the lower middle of the application under a tab named SVN Repositories. Right-click on the project you wish to download and choose Checkout. Fill in any relevant information, then click Finish. You will be prompted to enter a Project name; create one that works well for you. Choose the location where you wish to download the project and click Finish.
Once the project has completed the checkout process, you should find the downloaded files in the location you specified.
How can get the most benefit from the combination of Eclipse, Subversion, and Google Code? Suppose you're the lone developer on a project, and you use Subclipse to manage changes to the project code repository. If I'm interested in testing your changes, I can use SVN checkout to grab the latest copy of your code. Once I've done my testing, I can email you and share ideas or bugs from the latest code.
Bottom line: Using SVN with Eclipse allows developers to upload to a project hosting site with speed and ease. Subclipse in particular makes it easy to exchange project code at Google Code.
This work is licensed under a Creative Commons Attribution 3.0 Unported License