I've missed the news, but it can be extremely useful : since version 3.2 of Eclipse, it is possible to apply the formatting of Java code to a set of source files. This functionality is accessible via the command line.
The following example runs the formatting of code specified by the configuration file D:/formatter.prefs on the files Java belonging (directly or indirectly) to the directory D:/tmp/src :
The code formatter configuration file can be obtained in the following way:
The following example runs the formatting of code specified by the configuration file D:/formatter.prefs on the files Java belonging (directly or indirectly) to the directory D:/tmp/src :
eclipse -application org.eclipse.jdt.core.JavaCodeFormatter -config D:/formatter.prefs D:/tmp/src
The code formatter configuration file can be obtained in the following way:
- In Eclipse, open the properties of a Java project.
- In Code Style > Formatter, check Enable project specific settings.
- Select and edit a formatter configuration.
- Click on OK.
- The code formatter configuration file will then be in your Eclipse workspace in workspace/YourJavaProject/.settings/org.eclipse.jdt.core.prefs.