Synchronizing Eclipse .classpath in code repository

My team handles several Java projects using Eclipse, and shares the code using a code repository.

When a developer adds, removes or updates a jar file, the build is broken for everybody else, until they update their build path in Eclipse. This process involves cumbersome email synchronization.

  • What's (by default) on the classpath when you run a Jenkins job?
  • How best to handle .classpath files in Git when developers are using different versions of JBoss in their project build paths?
  • SVN:ignore how-to and on what?
  • How to deal best with SVN and local changes, that should not be committed?
  • Jenkins Running on Websphere 8.5 causes plugin class load errors
  • git - push java .classpath file?
  • For several reasons, we have decided not to commit the .classpath file to the repo. Instead, we came up with the following idea: Each project will have a committed file, say jars.list, which contains a list of jar files (and patterns). A script will convert this file into a local .classpath for eclipse. Whenever a developer changes its jars, it is his or her responsibility to change jars.list and commit it.

    Is this a reasonable solution? Are there any existing solutions for this problem?

  • Converting a development team from FTP to a Versioning System
  • What is the best way to convert a CVS project with many modules into one git repository?
  • Git, SVN & Mercurial Whats is Ideally the best SCM?
  • Netbeans Version Control File Color Codes?
  • Find deleted files in Mercurial repository history, quickly?
  • How does git blame determine who edited a line of a file?
  • 2 Solutions collect form web for “Synchronizing Eclipse .classpath in code repository”

    Eclipse .project and .classpath files are intended/designed to be checked into a version control repository (cvs, svn, git, etc). See this page in the Eclipse wiki.

    There are various ways to keep the .classpath file “clean” (ie, free from absolute paths), which I mentioned in the Comments section above.

    The build is broken because the absolute path to the JAR is different in each developer machine? If so, you could add a user variable to avoid the issue, this way each developer only have to configure one variable (like LIB_DIR):

    <classpathentry kind="var" path="LIB_DIR/path/to/file.jar"/>

    There are other solutions. You could configure some user libraries in eclipse to group your JARs, and then export a .userlibraries file which could be shared in your repo. This way, there would be no absolute paths in .classpath, but they would be present in your .userlibraries.

    You could also use some tool like Maven to manage dependencies on your project.

    Anyway, I think you could share .classpath without problems…

    Git Baby is a git and github fan, let's start git clone.