Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java project: should .classpath .project file be committed into repository? [duplicate]

Should I check in my .project and .classpath files?

My friend told me that I should only check in .java files and the build.xml to guarantee portability. He said ".classpath will cause you much less portability on different environment. .project is entirely your local eclipse setting"

I agree with him, but partially.

-- Not checking in .project file will make my development less efficient (I can't simply "import" a project code from a directory)

-- Not checking in .classpath file seems OK to me (?) if my build.xml is written carefully.

Anyone wants to share their experience here?

like image 352
sean Avatar asked Aug 31 '10 17:08

sean


2 Answers

There is nothing wrong with checking in .project and .classpath. I would do so, if your build.xml isn't able to create both of the files for you. As you said, it's uncomfortable to miss these files when you try to create a new eclipse workspace.

Before you check in .classpath you should be sure that there is no absolute path in it. Convert it into a relative one with a text editor.

Edit: Or even better, use eclipse classpath variables in your otherwise absolute pathes, like @taylor-leese commented.

like image 180
tangens Avatar answered Oct 05 '22 20:10

tangens


For my 2 cents, I would rate it as a bad practice. Projects should not be tied to an IDE, and especially should not be tied to a specific version of an IDE.

Checking in Eclipse config files might work well for simpler and short-term projects. For larger projects that are developed over several years this will generally cause more hassle, as IDE versions change, and project config files don't. Just imagine checking in a 2 year old branch with Eclipse 2.0 config files in Eclipse 4.3 with some customized libraries and m2e integration... No fun at all...

like image 42
Nick G. Avatar answered Oct 05 '22 18:10

Nick G.