Checkout a project from svn – the right way

Do you use eclipse? Do you use svn? Did you ever checked out a new project into your workspace?

If you could answer all these questions with a “yes” you might have noticed afterwards that you can’t do anything with this project because eclipse created it as “general project”, meaning no java, php or anything other specialized nature. This results in certain functions like Run as Java application not being accessable.

There are several solutions to that problem – but most of them are really ugly, imho. But since I don’t want to keep anything from you I will explain these methods too. So let’s get started…

The wrong way

The intuitive way you propably would start the task “to checkout a new project from SVN” might be “File -> New -> Project -> Others…-> Checkout a project from SVN”. In the result you’d have the previously mentioned “general project” which is pretty useless.

solution #1: edit .project

After the creation of the new project you quit eclipse, browse to the project folder in your file system and open the .project-file in a editor.

You’ll find these lines:

<natures>
</natures>

Change it to match:

<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>

Save the file and fire up eclipse again, you will have your svn-project recognized as Java-project. This solution might be quick but the drawbacks are the quit/edit/start-sequence outside of eclipse and the necessity to find the right “nature” for your svn project.

solution #2: delete and recreate

After having completed the checkout you will delete your project. Yes, you read right. (I told you these methods are ugly! 😉 ) But when deleting be sure you don’t check the box for physically deletion of the files (so they’ll remain inside your workspace).

When you finished deleting the project you create a new project for the kind of project the svn project should represent (i.e. java, php etc.). While in the creation wizard be sure you select the same folder where the svn project has been checked out into.

The newly created project will have the right project type and will contain all files from the repository. Sometimes it is necessary to refresh the workspace (windows: hit F5 on the project).

Although this method also results in having the right data with the correct project type it has a bad taste jumping through these hoops in order to finish a simple task like that.

Since I wasn’t pleased with all those solutions I kept on looking. Finally I found…

The right way

Besides the following solution is the one most hoopless (no pun intended) the claim “right” is justified because it seems that this is the way the eclipse devs want us to check out a project.

In order to accomplish the task at hand you have to

  • open the SVN Exploring-perspective
    ( Windows -> Open Perspective -> Other… -> SVN Exploring)
  • create a new repository location or select the desired source
  • browse to the parent folder of your new project (e.g. trunk)
  • right click on the folder, choose Checkout…
  • in the new dialogue you will have the chance to select Check out as a project configured using the New Project Wizard, take that chance, fill out the rest as you please and hit Finish
  • in the new project wizard which will open next you can choose your desired project type (e.g. java) and set up everything like you would in a normal project (e.g. compliler compliance level, JRE, related projects etc.)
  • after hitting this finish button you will notice that the svn is queried to retrieve the code
  • and you’re done!

In my opinion this way is the most hazzle-free way to check out a new project though I love to see it the other way around too (New->Project->New Project from SVN -> yada yada yada -> “Please select a project type or press OK to let it remain a generel project.”). Until this is implemented I will go with the second best solution.

About stevie

Born in the north of Germany, raised in Berlin and stayed there since. After graduating, studying applied computer science at the FHTW Berlin (now HTW Berlin), I started my own company with a former fellow student, providing high class application solutions for web and desktop for small and medium companies (see www.jnamic.com (english version to be finished) for more information). My personal favorite programming languages are PHP for the web and Java for everything else - although I must admit Java evolved very much in the past few years. I love to code and build new applications from the scratch, optimizing it through day and night till I am satisfied with it's performance. So follow my articles, share your thoughts and experience with me and have a good time browsing this blog!
This entry was posted in common and tagged , , , , . Bookmark the permalink.