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

Viewed 30747

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?

10 Answers

I often have a similar, more general questionning. The problem essentially is :

  • which files am I commiting for me?
  • which files am I commiting for others?
  • → How do I combine both objectives of "versionning"?

I offered discussing this there, so you may find more details about the problem, along with interesting solutions :)


The one I like best is the use of git submodule: keep your .project files etc. in a private commit repo. And make your final, pure, essential src production into a neat submodule nugget: a public repo.

project/ # root module
|   .git # private repo
|   .project
|   .classpath
|   momsNumber.txt
+---src/     # submodule
|   |   .git # public repo
|   |   main.java
|   +---package/
|   |   |    Etc.java

See there anyway.

Related