formatter:format

Full name:

net.revelc.code.formatter:formatter-maven-plugin:2.8.1:format

Description:

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.

Attributes:

  • Requires a Maven project to be executed.
  • Binds by default to the lifecycle phase: process-sources.

Required Parameters

Name Type Since Description
<compilerCompliance> String - Java compiler compliance version.
Default value is: 1.8.
User property is: maven.compiler.source.
<compilerSource> String - Java compiler source version.
Default value is: 1.8.
User property is: maven.compiler.source.
<compilerTargetPlatform> String - Java compiler target version.
Default value is: 1.8.
User property is: maven.compiler.target.
<configCssFile> String - File or classpath location of a properties file to use in css formatting.
Default value is: formatter-maven-plugin/ph-css/css.properties.
User property is: configcssfile.
<configFile> String - File or classpath location of an Eclipse code formatter configuration xml file to use in formatting.
Default value is: formatter-maven-plugin/eclipse/java.xml.
User property is: configfile.
<configHtmlFile> String - File or classpath location of a properties file to use in html formatting.
Default value is: formatter-maven-plugin/jsoup/html.properties.
User property is: confightmlfile.
<configJsFile> String - File or classpath location of an Eclipse code formatter configuration xml file to use in formatting.
Default value is: formatter-maven-plugin/eclipse/javascript.xml.
User property is: configjsfile.
<configJsonFile> String - File or classpath location of a properties file to use in json formatting.
Default value is: formatter-maven-plugin/jackson/json.properties.
User property is: configjsonfile.
<configXmlFile> String - File or classpath location of a properties file to use in xml formatting.
Default value is: formatter-maven-plugin/jsoup/xml.properties.
User property is: configxmlfile.
<encoding> String 0.3 The file encoding used to read and write source files. When not specified and sourceEncoding also not set, default is platform file encoding.
User property is: project.build.sourceEncoding.
<lineEnding> LineEnding 0.2.0 Sets the line-ending of files after formatting. Valid values are:
  • "AUTO" - Use line endings of current system
  • "KEEP" - Preserve line endings of files, default to AUTO if ambiguous
  • "LF" - Use Unix and Mac style line endings
  • "CRLF" - Use DOS and Windows style line endings
  • "CR" - Use early Mac style line endings

Default value is: AUTO.
User property is: lineending.
<sourceDirectory> File - Project's source directory as specified in the POM.
Default value is: ${project.build.sourceDirectory}.
User property is: sourceDirectory.
<testSourceDirectory> File - Project's test source directory as specified in the POM.
Default value is: ${project.build.testSourceDirectory}.
User property is: testSourceDirectory.

Optional Parameters

Name Type Since Description
<directories> File[] 0.4 Location of the Java source files to format. Defaults to source main and test directories if not set. Deprecated in version 0.3. Reintroduced in 0.4.
<excludes> String[] 0.3 List of fileset patterns for Java source locations to exclude from formatting. Patterns are relative to the project source and test source directories. When not specified, there is no default exclude.
<includes> String[] 0.3 List of fileset patterns for Java source locations to include in formatting. Patterns are relative to the project source and test source directories. When not specified, the default include is **/*.java
User property is: formatter.includes.
<skipCssFormatting> Boolean - Whether the css formatting is skipped.
Default value is: false.
User property is: formatter.css.skip.
<skipFormatting> Boolean 0.5 Whether the formatting is skipped.
Default value is: false.
User property is: formatter.skip.
Alias is: skip.
<skipHtmlFormatting> Boolean - Whether the html formatting is skipped.
Default value is: false.
User property is: formatter.html.skip.
<skipJavaFormatting> Boolean - Whether the java formatting is skipped.
Default value is: false.
User property is: formatter.java.skip.
<skipJsFormatting> Boolean - Whether the javascript formatting is skipped.
Default value is: false.
User property is: formatter.js.skip.
<skipJsonFormatting> Boolean - Whether the json formatting is skipped.
Default value is: false.
User property is: formatter.json.skip.
<skipXmlFormatting> Boolean - Whether the xml formatting is skipped.
Default value is: false.
User property is: formatter.xml.skip.
<useEclipseDefaults> Boolean - Use eclipse defaults when set to true for java and javascript.
Default value is: false.
User property is: formatter.useEclipseDefaults.

Parameter Details

<compilerCompliance>

Java compiler compliance version.
  • Type: java.lang.String
  • Required: Yes
  • User Property: maven.compiler.source
  • Default: 1.8

<compilerSource>

Java compiler source version.
  • Type: java.lang.String
  • Required: Yes
  • User Property: maven.compiler.source
  • Default: 1.8

<compilerTargetPlatform>

Java compiler target version.
  • Type: java.lang.String
  • Required: Yes
  • User Property: maven.compiler.target
  • Default: 1.8

<configCssFile>

File or classpath location of a properties file to use in css formatting.
  • Type: java.lang.String
  • Required: Yes
  • User Property: configcssfile
  • Default: formatter-maven-plugin/ph-css/css.properties

<configFile>

File or classpath location of an Eclipse code formatter configuration xml file to use in formatting.
  • Type: java.lang.String
  • Required: Yes
  • User Property: configfile
  • Default: formatter-maven-plugin/eclipse/java.xml

<configHtmlFile>

File or classpath location of a properties file to use in html formatting.
  • Type: java.lang.String
  • Required: Yes
  • User Property: confightmlfile
  • Default: formatter-maven-plugin/jsoup/html.properties

<configJsFile>

File or classpath location of an Eclipse code formatter configuration xml file to use in formatting.
  • Type: java.lang.String
  • Required: Yes
  • User Property: configjsfile
  • Default: formatter-maven-plugin/eclipse/javascript.xml

<configJsonFile>

File or classpath location of a properties file to use in json formatting.
  • Type: java.lang.String
  • Required: Yes
  • User Property: configjsonfile
  • Default: formatter-maven-plugin/jackson/json.properties

<configXmlFile>

File or classpath location of a properties file to use in xml formatting.
  • Type: java.lang.String
  • Required: Yes
  • User Property: configxmlfile
  • Default: formatter-maven-plugin/jsoup/xml.properties

<directories>

Location of the Java source files to format. Defaults to source main and test directories if not set. Deprecated in version 0.3. Reintroduced in 0.4.
  • Type: java.io.File[]
  • Since: 0.4
  • Required: No

<encoding>

The file encoding used to read and write source files. When not specified and sourceEncoding also not set, default is platform file encoding.
  • Type: java.lang.String
  • Since: 0.3
  • Required: Yes
  • User Property: project.build.sourceEncoding

<excludes>

List of fileset patterns for Java source locations to exclude from formatting. Patterns are relative to the project source and test source directories. When not specified, there is no default exclude.
  • Type: java.lang.String[]
  • Since: 0.3
  • Required: No

<includes>

List of fileset patterns for Java source locations to include in formatting. Patterns are relative to the project source and test source directories. When not specified, the default include is **/*.java
  • Type: java.lang.String[]
  • Since: 0.3
  • Required: No
  • User Property: formatter.includes

<lineEnding>

Sets the line-ending of files after formatting. Valid values are:
  • "AUTO" - Use line endings of current system
  • "KEEP" - Preserve line endings of files, default to AUTO if ambiguous
  • "LF" - Use Unix and Mac style line endings
  • "CRLF" - Use DOS and Windows style line endings
  • "CR" - Use early Mac style line endings
  • Type: net.revelc.code.formatter.LineEnding
  • Since: 0.2.0
  • Required: Yes
  • User Property: lineending
  • Default: AUTO

<skipCssFormatting>

Whether the css formatting is skipped.
  • Type: java.lang.Boolean
  • Required: No
  • User Property: formatter.css.skip
  • Default: false

<skipFormatting>

Whether the formatting is skipped.
  • Type: java.lang.Boolean
  • Since: 0.5
  • Required: No
  • User Property: formatter.skip
  • Default: false
  • Alias: skip

<skipHtmlFormatting>

Whether the html formatting is skipped.
  • Type: java.lang.Boolean
  • Required: No
  • User Property: formatter.html.skip
  • Default: false

<skipJavaFormatting>

Whether the java formatting is skipped.
  • Type: java.lang.Boolean
  • Required: No
  • User Property: formatter.java.skip
  • Default: false

<skipJsFormatting>

Whether the javascript formatting is skipped.
  • Type: java.lang.Boolean
  • Required: No
  • User Property: formatter.js.skip
  • Default: false

<skipJsonFormatting>

Whether the json formatting is skipped.
  • Type: java.lang.Boolean
  • Required: No
  • User Property: formatter.json.skip
  • Default: false

<skipXmlFormatting>

Whether the xml formatting is skipped.
  • Type: java.lang.Boolean
  • Required: No
  • User Property: formatter.xml.skip
  • Default: false

<sourceDirectory>

Project's source directory as specified in the POM.
  • Type: java.io.File
  • Required: Yes
  • User Property: sourceDirectory
  • Default: ${project.build.sourceDirectory}

<testSourceDirectory>

Project's test source directory as specified in the POM.
  • Type: java.io.File
  • Required: Yes
  • User Property: testSourceDirectory
  • Default: ${project.build.testSourceDirectory}

<useEclipseDefaults>

Use eclipse defaults when set to true for java and javascript.
  • Type: java.lang.Boolean
  • Required: No
  • User Property: formatter.useEclipseDefaults
  • Default: false