Eclipse changes project timestamp comment after validation

I have an Eclipse workspace with many (> 50) packages. Some packages contain special project settings, for example, formatting client code.

If I create a new workspace and check out an existing project with client code formatting, Eclipse automatically changes the date comment in org.eclipse.jdt.ui.prefs to the current date!

This is the preference file ( org.eclipse.jdt.ui.prefs ) in SVN:

 #Tue Apr 24 09:15:20 CEST 2012 eclipse.preferences.version=1 formatter_profile=_myProfile formatter_settings_version=12 

This is the file ( org.eclipse.jdt.ui.prefs ) after checking:

 #Tue Apr 24 09:30:25 CEST 2012 eclipse.preferences.version=1 formatter_profile=_myProfile formatter_settings_version=12 

The same thing happens with the org.eclipse.core.resources.prefs settings file if I set the encoding to UTF-8 for the whole project.

SVN:

 #Tue Apr 24 09:26:48 CEST 2012 eclipse.preferences.version=1 encoding/<project>=UTF-8 

After placing an order:

 #Tue Apr 24 09:28:00 CEST 2012 eclipse.preferences.version=1 encoding/<project>=UTF-8 

If the project contains both installation files ( org.eclipse.core.resources.prefs and org.eclipse.jdt.ui.prefs ), only the org.eclipse.core.resources.prefs settings file will be modified!

Does anyone know why Eclipse is changing this line and how can I avoid it?

+7
source share
3 answers

DO NOT save your eclipse settings in subversions !!! This does not allow you to have different settings or different versions of the eclipse. It will be a real pain if you have different conditions.

Consider using something like a Workspace Engine if you want to keep your workspace settings in sync.

If it is only for sharing your format settings, export them as XML and save the XML file in your repository. Each developer can import an XML file.

+6
source

In some cases, it puzzled me, but I'm not sure I can give you the full answer.

Firstly, my org.eclipse.core.resources.prefs files never include a timestamp! I have other preference files, such as org.eclipse.jdt.ui.prefs , which always have a timestamp. In my current setup, they never look overly updated.

There are several generations of preference APIs

  • org.eclipse.core.runtime.Preferences - Access via Plugin.getPluginPreferences() - Deprecated in Eclipse 3.0; Now imitated - do not use it!
  • org.eclipse.jface.preference.* - Access via AbstractUIPlugin.getPreferenceStore() - Replaced in Eclipse 3.1; now modeled - used for field editors
  • org.eclipse.core.runtime.preferences.* - Access via Platform.getPreferencesService() - based on the OSGi preference service

Those preferences that use the third generation API, reading and writing preference files, as always, occur through EclipsePreferences . This class does the β€œright” thing and removes the timestamp.

In some cases, for example, when formatting is processed in JDT, a special org.eclipse.jface.preference.PreferenceStore . This class will not work, just write a timestamp.

Why this class is used and exactly when it is used is not very clear from the code ...

One thing is certain, but I cannot find a way to avoid this!

+1
source

Could this be a line ending problem? Feature of your specific version of Eclipse?

I can imagine that Eclipse overwrites the configuration files without any noticeable significant changes if the EOL symbol used for the file in SVN does not conform to the standard on the machine used for development. In this case, you should only see a problem when switching computers. The fix will be to add the svn:eol-style = native property to the problem files.

I confine myself to reasoning about the problem because I cannot reproduce the behavior that you see with or without inconsistent line endings. I have numerous Eclipse projects with configuration files in a repo, and although they are often automatically changed by Eclipse in undesirable ways, they are always substantially changed. I cannot force the settings files to change only their data, simply importing their project on Eclipse Helios SR2 (which better matches the format of your settings files) or Eclipse SDK 3.7.2 (M20120208-0800). Perhaps just updating Eclipse will solve the problem (be sure to export your settings!).

+1
source

All Articles