The Eclipse Format Plugin is used to format java source files following coding convention configured with the Eclipse IDE.
This plugin will format all java source files in the sourceDirectory and, if specified, the testDirectory following the configured coding convention.
If no configuration file is specified, the default format file will be used.
<project> ... <build> ... <plugins> <plugin> <groupId>net.sf.maven.plugins</groupId> <artifactId>maven-eclipse-format</artifactId> <version>1.0</version> </plugin> </plugins> ... </build> ... </project>
You can use a custom configuration file placed in a directory of your liking. Exporting the code format rules can be done as follows:
Please note that build-in format profiles cannot be exported in Eclipse. You need to make your own profile, based on one of the build-in profiles, and export that one.
For this example we want to use the file src/config/sun-format-standards.xml. This is how you would configure that.
<project> ... <build> ... <plugins> <plugin> <groupId>net.sf.maven.plugins</groupId> <artifactId>maven-eclipse-format</artifactId> <version>1.0</version> <configuration> <formatConfig>${basedir}/src/config/sun-format-standards.xml</formatConfig> </configuration> </plugin> </plugins> ... </build> ... </project>
For all available configuration options see this page.
mvn eclipse-format:format