java-formatter:format

Full name:

com.googlecode.maven-java-formatter-plugin:maven-java-formatter-plugin:0.3.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 md5 hash of the content, comparing to the original hash to the hash after formatting and a cached hash.

Attributes:

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

Optional Parameters

Name Type Since Description
compilerCompliance String - Java compiler compliance version.
Default value is: 1.5.
compilerSource String - Java compiler source version.
Default value is: 1.5.
compilerTargetPlatform String - Java compiler target version.
Default value is: 1.5.
configFile String - File or classpath location of an Eclipse code formatter configuration xml file to use in formatting.
directories File[] - Deprecated. Use includes/excludes instead
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.
Default value is: ${project.build.sourceEncoding}.
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
lineEnding String 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.
overrideConfigCompilerVersion Boolean 0.2.0 Sets whether compilerSource, compilerCompliance, and compilerTargetPlatform values are used instead of those defined in the configFile.
Default value is: false.

Parameter Details

compilerCompliance:

Java compiler compliance version.
  • Type: java.lang.String
  • Required: No
  • Default: 1.5

compilerSource:

Java compiler source version.
  • Type: java.lang.String
  • Required: No
  • Default: 1.5

compilerTargetPlatform:

Java compiler target version.
  • Type: java.lang.String
  • Required: No
  • Default: 1.5

configFile:

File or classpath location of an Eclipse code formatter configuration xml file to use in formatting.
  • Type: java.lang.String
  • Required: No

directories:

Deprecated. Use includes/excludes instead
Location of the Java source files to format.
  • Type: java.io.File[]
  • 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: No
  • Default: ${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

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: java.lang.String
  • Since: 0.2.0
  • Required: No
  • Default: AUTO

overrideConfigCompilerVersion:

Sets whether compilerSource, compilerCompliance, and compilerTargetPlatform values are used instead of those defined in the configFile.
  • Type: java.lang.Boolean
  • Since: 0.2.0
  • Required: No
  • Default: false