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

sean picture sean · Aug 31, 2010 · Viewed 26.5k times · Source

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?

Answer

tangens picture tangens · Aug 31, 2010

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.