How to correctly version control (svn:ignore) a Java project (Maven, Spring)?

Robert Niestroj picture Robert Niestroj · Jun 10, 2011 · Viewed 13.3k times · Source

i was on a 2-day training introducing as to Java EE. We used there Java EE, Spring Framework, Maven, Springsource Tool Suite (Eclipse), Tomcat.

I took the Eclipse workspace we created there and run it on my work PC. I had, if i remember correctly, only to configure Tomcat properly, and it worked on my PC.

Now i want to save the created Eclipse workspace containing 5 "sub"-projects in subversion so that my work colleagues can checkout this to them and run it on their computers.

How to do this correctly? I found somewhere a svn:ignore rule:

.classpath
.project
.settings
target

Using tortoiseSVN i added to the folder with the workspace this ignore rule, but the found out that the underlying folders target were'nt deleted so i deleted them manually and "added to ignore list". But after that the project in spring source tool suite does not see the mevan dependencies (i think so) because the imports are broken. STS underlines org. in the imports and says it can not resolve this.

How do i correctly version control such a project?

Answer

Daniel Lundmark picture Daniel Lundmark · Jun 10, 2011

In my project we are using Maven and Eclipse (Helios, currently) and the Maven plugins for Eclipse:

Maven Integration for Eclipse Maven Integration for WTP

We only have the pom.xml file and the src/ directory tree in our version control system. We make sure not to add the eclipse files there. Then when a new developer starts in the project they do Import -> Maven -> Existing Maven Projects. The Maven plugins for Eclipse then set up perfect build paths, settings and so on.

This way it is also very easy to re-import your projects into Eclipse as needed.

So, my tip is to leave the Eclipse files out of SVN and make sure you can setup the project correctly automatically simply by importing a Maven project.