Plugin Documentation

Goals available for this plugin:

Goal Description
formatter:format A Maven plugin mojo to format Java source code using the Eclipse code formatter.

Mojo parameters allow customizing formatting by specifying the config XML file, line endings, compiler version, and source code locations. Reformatting source files is avoided using an sha512 hash of the content, comparing to the original hash to the hash after formatting and a cached hash.

formatter:help Display help information on formatter-maven-plugin.
Call mvn formatter:help -Ddetail=true -Dgoal=<goal-name> to display parameter details.
formatter:validate This mojo is very similar to Formatter mojo, but it is focused on CI servers.

If the code ain't formatted as expected this mojo will fail the build

System Requirements

The following specifies the minimum requirements to run this Maven plugin:

Maven 3.5.0
JDK 11

Usage

You should specify the version in your project's plugin configuration:

<project>
  ...
  <build>
    <!-- To define the plugin version in your parent POM -->
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>net.revelc.code.formatter</groupId>
          <artifactId>formatter-maven-plugin</artifactId>
          <version>2.23.0</version>
        </plugin>
        ...
      </plugins>
    </pluginManagement>
    <!-- To use the plugin goals in your POM or parent POM -->
    <plugins>
      <plugin>
        <groupId>net.revelc.code.formatter</groupId>
        <artifactId>formatter-maven-plugin</artifactId>
      </plugin>
      ...
    </plugins>
  </build>
  ...
</project>

For more information, see "Guide to Configuring Plug-ins"