22 Jul 2008

Eclipse, classpath and subversion

I always have the same problem over and over to make eclipse, the project classpath and subversion work perfectly together :(
And I'm pretty sure thousand of other guys have the same problem.

The problem is that you need to do 2 things to avoid the output dir to appears as a folder under source control:
  • add the output dir to the ignore list
  • AND
  • add an exclusion filter in the src dir to avoid eclipse to copy the .svn folder in the output dir
Example:
1- When you start a new eclipse project, you have that folder structure:





2- You add it to subversion but you don't want the output dir to be added so you just add the src folder:


3- You add the bin dir to the ignore list:


But you are not over yet! At this stage subversion doesn't complain anymore about uncommited changes in bin BUT you still have the .svn folder in bin.

This is specially anoying with tortoise svn since it displays svn icons on the bin folder.

4- Now you need to exclude the .svn from the src folder to prevent eclipse to copy them:




Does anybody knows how this can be achieve under Maven when using "mvn eclipse:eclipse" ?
I suppose one need to use the filters as describe in the pom reference...




6 comments:

Joel Sanderson said...

I found your post looking for an answer to the same question!

Not sure about having it ignore the .svn directory, but you can get Eclipse to behave (by not copying the .svn directory to bin) by installing Subclipse and "sharing" the project. Here are instructions on installing Subclipse, below. I'm using Ganymede (Eclipse 3.4.0).

http://subclipse.tigris.org/install.html

One thing after installing: If you already have your workspace set up with projects, you have to do this:
1) Right-click on the project in the package explorer
2) Go to "Team"->"Share Project" (or similar)
3) Select SVN (if that isn't there, then Subclipse might not be installed correctly.)
4) Click next, etc. It'll say it's already been shared by an external tool. Click "Finish"

You should be done! Just delete the .svn folders from your bin directory.

Good luck!

Unknown said...

Thank you thank you thank you! This was exactly what I needed.

Anonymous said...

Just had the same problem and solved it. Project properties, Java Build Path, Sources, Exclude, Edit and .svn/**. Voila! :)

MrPhil said...

Thanks for this. It helped me solve my issues. One thing I found, the wildcard **/.svn/** works better. It keeps ALL the .svn folders out of the bin, not just the one at the top level.

Crirus said...

I hate this thing, I really do...

I tried all to make it work my desired way with no luck.

I want src svn files ignored on build, but I want my out put folder subversioned as well.

When I ignore in src, all subversion files and folders in out put get deleted.

can't Eclipse just ignore in output as well??

Benjamin Francisoud said...

@Crirus

I don't think you should version the .class personnaly I consider it a bad idea because:
- you can't diff a binary
- if you versionned the src why do you need the binary ?
- you don't need versionning on a binary, you need archiving and svn is not an archiving tool (a distributed drive, a CD/DVD, a flash card, an ftp server etc... are tools to archive binaries)

my 2 cents