8

We'd like to find a "lightweight" method of enforcing code standards prior to check-in. We really like the idea of using Eclipse's built-in Save Actions (go to Preferences >> Java >> Editor >> Save Actions) which has a Format source code function that can run every time the developer saves a file.

This way, so long as each developer using the same format rules, and has Save Actions enabled, we can be fairly comfortable that by the time code makes it to review, that our code standards have been enforced (for the most part).

What I'm trying to figure out is: what file(s) does Eclipse use to save these format rules to? How could I keep such a file in source control, and have developers check it out?

  • Where is it located (within the workspace)?
IAmYourFaja
  • 55,468
  • 181
  • 466
  • 756

1 Answers1

6

The workspace-wide save action configuration is stored in your workspace directory in this file:

WORKSPACE-DIR\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.jdt.ui.prefs

Adding this file to source control would be somewhat tricky, as it is workspace-specific and not project-specific. You can however, enable project-specific save action configuration via the save action wizard. In that case, the configuration is stored in your project path, under:

PROJECT-DIR\.settings\org.eclipse.jdt.ui.prefs

This file can easily be put under source code control.

joergl
  • 2,850
  • 4
  • 36
  • 42
  • Wow - great eye, joergl! I'm looking at the `org.eclipse.jdt.ui.prefs` file now and it is absolutely massive! It looks like it hold other information besides Save Action info - is this true? If so, is there anything in this file that is project- or developer-specific? I ask because I think the remedy here is to just get a version of this file in a repository somewhere, and ask each developer to copy it down. This should work so long as each developer is on the same version of Eclipse and *if* the `org.eclipse.jdt.ui.prefs` file *only* contains Save Action data...what do you think? – IAmYourFaja Feb 11 '12 at 02:09
  • Ah, good question. Unfortunately, I do not know all options that go into this file for sure. I tested it in a fresh project and workspace, so there was only save action configuration in my file. Afaik, it is the configuration file for the Java Editor, so I guess everything you can configure for this editor goes into this file. So, there might be issues with different eclipse versions, because of different parameter sets. If I was in your position, I would just try and see. At least, a google search for the file name reveals, it seems to be common practice to put this file in source control. – joergl Feb 11 '12 at 15:58