We rely on Eclipse formatter in our project to enforce formatting conventions for us. It works great and we really like it.
We keep the formatter file with our project in source control and ask everybody to import this formatter to Eclipse. The only serious problem is that whenever somebody modifies the formatter and commits the change, then every team member needs to manually “reimport” the formatter. And it’s easy to forget about doing it, so we often end up with using different versions of formatter among the team.
Is there any way to make Eclipse automatically use new version of formatter when the formatter file is updated? (I mean, could we just say to Eclipse “here’s the path to formatter file, always use the current version of this file as a formatter”?) It would be great!
Any ideas?
Introduction
Formatter, Code Templates, etc. can be stored as project specific settings in the folder
.settings/. You don’t necessarily need to re-import the Formatter in your workspace.You can use project specific settings in combination with
svn:externalsto “inject” the formatter, code templates, etc. in your projects.Projects
com.xyz.codeconventionswhere we added a project specific formatter and code templates. This project is under version control.svn:externalsproperty to “inject” the.settings/folder from the projectcom.xyz.codeconventions(This is the folder where the project specific data is stored)com.xyz.codeconventionsand usesvn committo submit the changes. The team will have tosvn updateon all projects to get the latest version of the code formatter.Configuration
For all projects which should use this formatter you have to define a svn:externals property.
Example for com.xyz.project1:
In Eclipse (in my case Subversive) you can add svn specific properties with
Team -> Set property....Repository Layout
The repository structure in our case looks like this:
<root> | +-- com.xyz.project1 # (svn:externals -> <root>/codeconventions/.settings .settings) | | | +-- src | +-- <...> +-- com.xyz.project2 # (svn:externals -> <root>/codeconventions/.settings .settings) | | | +-- src | +-- <...> +-- com.xyz.codeconventions | +-- .settings # (this folder will get "injected" in project1 and project2) | +-- org.eclipse.jdt.core.prefs +-- org.eclipse.jdt.ui.prefsAdditional comments / Limitations
svnusers only but if you usegitthere is something similar to svn:externals named Submodules..settings/-folder because withsvn:externalsit is not possible to overwrite existing files..settings/folder this approach is probably not what you are looking for. Our projects always have the same.settingsfiles.Sources