8

We have several devs in the team, the source code is managed using the Mercurial DVCS.

The .metadata folder is not under the source control.

The problem, is that when I configure project dependencies (jars, user libraries, source code paths, etc ...) they are stored inside the .metadata folder, namely in .metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.jdt.core.prefs

Since this file is not managed by DVCS, all the devs need to repeat the project configuration process all over again. For a new dev in the team this is a major head ache.

My question is there a sane procedure to share this kind of configuration data? I am new to the world of Java and Eclipse, so maybe I am missing something really basic here.

EDIT

The problem is that I have been using User Libraries, which are defined globally and thus are not shared. Using External Jars solves the problem, because these are recorded in the .classpath file inside the project directory.

Lii
  • 11,553
  • 8
  • 64
  • 88
mark
  • 59,016
  • 79
  • 296
  • 580

3 Answers3

7

You can prepare a preferences file (.epf) and store it in source control. Each developer will have to import this file once in each workspace they're using.

To create a preference file, go to File → Export... → General → Preferences. You can then edit the .epf file, so that it only contains the preferences you want to share with everyone. This way you can share code style preferences, formatting options, compiler warnings, JRE settings, UI tweaks, and many more types of Eclipse preferences.

Eli Acherkan
  • 6,401
  • 2
  • 27
  • 34
4

A short answer would be - use an IDE-independent project configuration tool like Maven.

Another possibility is ant - a very powerful build tool. Slightly out-of-vogue lately.

Sharing the buidfiles used by such a tool is a very common option for making your project settings and dependencies managable and easily portable.

Sharing the eclipse-generated metadata is on the other hand discouraged as eclipse stores dependencies with their absolute pathes (not sure if this is always the case, but definitely sometimes), and those pathes can cause a set of issues (experienced first-hand). Especially if shared between OS borders (win-linux)

kostja
  • 60,521
  • 48
  • 179
  • 224
4

You can specify a lot of properties in the project configuration instead of in the global configuration. Just right-click on the project and select "Properties" there.

Eclipse then saves the preferences in the project directory instead of in the workspace configuration directory. That way you can check-in the project specific configuration into your SCM and share it with other project members.

Witek
  • 6,160
  • 7
  • 43
  • 63
  • And note: The problem, is that when I configure project dependencies (jars, user libraries, source code paths, etc ...) they are stored inside the .metadata folder, namely in .metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.jdt.core.prefs ... this is not really correct. Project dependencies and jar file dependencies etc are stored in the .classpath file. The .metadata folder contains metadata of your eclipse installation (which plugins you have e.g.) it does not contain project settings like classpthes etc. – Angel O'Sphere Nov 29 '11 at 13:34
  • "Just right-click on the project and select "Preferences" there" - I don't have such a menu item in either Eclipse Helios or Indigo. Can you elaborate? – Eli Acherkan Nov 29 '11 at 13:37
  • Right. But from the question was not clear which preferences the user wants to share. Code style, Java-Version and a lot more can be saved either for the local eclipse workspace or like I suggested in the project specific properties. – Witek Nov 29 '11 at 13:40
  • Sorry. Its "Properties" at the bottom of the context menu. – Witek Nov 29 '11 at 13:42
  • If mark is looking for a way to store user libraries definitions, I don't see how it could be done in the project's "Properties" page. – Eli Acherkan Nov 29 '11 at 13:54
  • _User_ library definitions? Where exactly? – Eli Acherkan Nov 29 '11 at 14:24
  • USER library definitions are a way to allow each developer to add a set of jars configured on their machine (per workspace). The library name is added to the `.classpath` but not the library contents. – Paul Webster Nov 29 '11 at 14:52
  • Right. Which ist a good solution, because that way each developer can use his favorite OS with ist own library locations and still share the information about required libraries with others. – Witek Nov 29 '11 at 15:03