compiler:compile

Full name:

org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile

Description:

Compiles application sources

Attributes:

  • Requires a Maven project to be executed.
  • Requires dependency resolution of artifacts in scope: compile.
  • The goal is thread-safe and supports parallel builds.
  • Since version: 2.0.
  • Binds by default to the lifecycle phase: compile.

Optional Parameters

Name Type Since Description
annotationProcessors String[] 2.2

Names of annotation processors to run. Only applies to JDK 1.6+ If not set, the default annotation processors discovery process applies.


compilerArgument String 2.0

Sets the unformatted single argument string to be passed to the compiler if fork is set to true. To pass multiple arguments such as -Xmaxerrs 1000 (which are actually two arguments) you have to use compilerArguments.

This is because the list of valid arguments passed to a Java compiler varies based on the compiler version.


compilerArguments Map 2.0.1

Sets the arguments to be passed to the compiler (prepending a dash) if fork is set to true.

This is because the list of valid arguments passed to a Java compiler varies based on the compiler version.

To pass -Xmaxerrs 1000 -Xlint -Xlint:-path -Averbose=true you should include the following:

<compilerArguments>
  <Xmaxerrs>1000</Xmaxerrs>
  <Xlint/>
  <Xlint:-path/>
  <Averbose>true</Averbose>
</compilerArguments>

compilerId String 2.0 The compiler id of the compiler to use. See this guide for more information.
Default value is: javac.
compilerReuseStrategy String 2.5 Strategy to re use javacc class created:
  • reuseCreated (default): will reuse already created but in case of multi-threaded builds, each thread will have its own instance
  • reuseSame: the same Javacc class will be used for each compilation even for multi-threaded build
  • alwaysNew: a new Javacc class will be created for each compilation
Note this parameter value depends on the os/jdk you are using, but the default value should work on most of env.
Default value is: ${reuseCreated}.
compilerVersion String 2.0 Version of the compiler to use, ex. "1.3", "1.5", if fork is set to true.
debug boolean 2.0 Set to true to include debugging information in the compiled class files.
Default value is: true.
debuglevel String 2.1 Keyword list to be appended to the -g command-line switch. Legal values are none or a comma-separated list of the following keywords: lines, vars, and source. If debug level is not specified, by default, nothing will be appended to -g. If debug is not turned on, this attribute will be ignored.
encoding String 2.1 The -encoding argument for the Java compiler.
Default value is: ${project.build.sourceEncoding}.
excludes Set 2.0 A list of exclusion filters for the compiler.
executable String 2.0 Sets the executable of the compiler to use when fork is true.
failOnError boolean 2.0.2 Indicates whether the build will continue even if there are compilation errors.
Default value is: true.
fork boolean 2.0 Allows running the compiler in a separate process. If false it uses the built in compiler, while if true it will use an executable.
Default value is: false.
generatedSourcesDirectory File 2.2

Specify where to place generated source files created by annotation processing. Only applies to JDK 1.6+


Default value is: ${project.build.directory}/generated-sources/annotations.
includes Set 2.0 A list of inclusion filters for the compiler.
maxmem String 2.0.1 Sets the maximum size, in megabytes, of the memory allocation pool, ex. "128", "128m" if fork is set to true.
meminitial String 2.0.1 Initial size, in megabytes, of the memory allocation pool, ex. "64", "64m" if fork is set to true.
optimize boolean 2.0 Set to true to optimize the compiled code using the compiler's optimization methods.
Default value is: false.
outputFileName String 2.0 Sets the name of the output file when compiling a set of sources to a single file.
proc String 2.2

Sets whether annotation processing is performed or not. Only applies to JDK 1.6+ If not set, both compilation and annotation processing are performed at the same time.

Allowed values are:

  • none - no annotation processing is performed.
  • only - only annotation processing is done, no compilation.

showDeprecation boolean 2.0 Sets whether to show source locations where deprecated APIs are used.
Default value is: false.
showWarnings boolean 2.0 Set to true to show compilation warnings.
Default value is: false.
skipMultiThreadWarning boolean 2.5 (no description)
Default value is: ${false}.
source String 2.0 The -source argument for the Java compiler.
Default value is: 1.5.
staleMillis int 2.0 Sets the granularity in milliseconds of the last modification date for testing whether a source needs recompilation.
Default value is: 0.
target String 2.0 The -target argument for the Java compiler.
Default value is: 1.5.
verbose boolean 2.0 Set to true to show messages about what the compiler is doing.
Default value is: false.

Parameter Details

annotationProcessors:

Names of annotation processors to run. Only applies to JDK 1.6+ If not set, the default annotation processors discovery process applies.

  • Type: java.lang.String[]
  • Since: 2.2
  • Required: No

compilerArgument:

Sets the unformatted single argument string to be passed to the compiler if fork is set to true. To pass multiple arguments such as -Xmaxerrs 1000 (which are actually two arguments) you have to use compilerArguments.

This is because the list of valid arguments passed to a Java compiler varies based on the compiler version.

  • Type: java.lang.String
  • Since: 2.0
  • Required: No

compilerArguments:

Sets the arguments to be passed to the compiler (prepending a dash) if fork is set to true.

This is because the list of valid arguments passed to a Java compiler varies based on the compiler version.

To pass -Xmaxerrs 1000 -Xlint -Xlint:-path -Averbose=true you should include the following:

<compilerArguments>
  <Xmaxerrs>1000</Xmaxerrs>
  <Xlint/>
  <Xlint:-path/>
  <Averbose>true</Averbose>
</compilerArguments>
  • Type: java.util.Map
  • Since: 2.0.1
  • Required: No

compilerId:

The compiler id of the compiler to use. See this guide for more information.
  • Type: java.lang.String
  • Since: 2.0
  • Required: No
  • Expression: ${maven.compiler.compilerId}
  • Default: javac

compilerReuseStrategy:

Strategy to re use javacc class created:
  • reuseCreated (default): will reuse already created but in case of multi-threaded builds, each thread will have its own instance
  • reuseSame: the same Javacc class will be used for each compilation even for multi-threaded build
  • alwaysNew: a new Javacc class will be created for each compilation
Note this parameter value depends on the os/jdk you are using, but the default value should work on most of env.
  • Type: java.lang.String
  • Since: 2.5
  • Required: No
  • Expression: ${maven.compiler.compilerReuseStrategy}
  • Default: ${reuseCreated}

compilerVersion:

Version of the compiler to use, ex. "1.3", "1.5", if fork is set to true.
  • Type: java.lang.String
  • Since: 2.0
  • Required: No
  • Expression: ${maven.compiler.compilerVersion}

debug:

Set to true to include debugging information in the compiled class files.
  • Type: boolean
  • Since: 2.0
  • Required: No
  • Expression: ${maven.compiler.debug}
  • Default: true

debuglevel:

Keyword list to be appended to the -g command-line switch. Legal values are none or a comma-separated list of the following keywords: lines, vars, and source. If debug level is not specified, by default, nothing will be appended to -g. If debug is not turned on, this attribute will be ignored.
  • Type: java.lang.String
  • Since: 2.1
  • Required: No
  • Expression: ${maven.compiler.debuglevel}

encoding:

The -encoding argument for the Java compiler.
  • Type: java.lang.String
  • Since: 2.1
  • Required: No
  • Expression: ${encoding}
  • Default: ${project.build.sourceEncoding}

excludes:

A list of exclusion filters for the compiler.
  • Type: java.util.Set
  • Since: 2.0
  • Required: No

executable:

Sets the executable of the compiler to use when fork is true.
  • Type: java.lang.String
  • Since: 2.0
  • Required: No
  • Expression: ${maven.compiler.executable}

failOnError:

Indicates whether the build will continue even if there are compilation errors.
  • Type: boolean
  • Since: 2.0.2
  • Required: No
  • Expression: ${maven.compiler.failOnError}
  • Default: true

fork:

Allows running the compiler in a separate process. If false it uses the built in compiler, while if true it will use an executable.
  • Type: boolean
  • Since: 2.0
  • Required: No
  • Expression: ${maven.compiler.fork}
  • Default: false

generatedSourcesDirectory:

Specify where to place generated source files created by annotation processing. Only applies to JDK 1.6+

  • Type: java.io.File
  • Since: 2.2
  • Required: No
  • Default: ${project.build.directory}/generated-sources/annotations

includes:

A list of inclusion filters for the compiler.
  • Type: java.util.Set
  • Since: 2.0
  • Required: No

maxmem:

Sets the maximum size, in megabytes, of the memory allocation pool, ex. "128", "128m" if fork is set to true.
  • Type: java.lang.String
  • Since: 2.0.1
  • Required: No
  • Expression: ${maven.compiler.maxmem}

meminitial:

Initial size, in megabytes, of the memory allocation pool, ex. "64", "64m" if fork is set to true.
  • Type: java.lang.String
  • Since: 2.0.1
  • Required: No
  • Expression: ${maven.compiler.meminitial}

optimize:

Set to true to optimize the compiled code using the compiler's optimization methods.
  • Type: boolean
  • Since: 2.0
  • Required: No
  • Expression: ${maven.compiler.optimize}
  • Default: false

outputFileName:

Sets the name of the output file when compiling a set of sources to a single file.
  • Type: java.lang.String
  • Since: 2.0
  • Required: No
  • Expression: ${project.build.finalName}

proc:

Sets whether annotation processing is performed or not. Only applies to JDK 1.6+ If not set, both compilation and annotation processing are performed at the same time.

Allowed values are:

  • none - no annotation processing is performed.
  • only - only annotation processing is done, no compilation.
  • Type: java.lang.String
  • Since: 2.2
  • Required: No

showDeprecation:

Sets whether to show source locations where deprecated APIs are used.
  • Type: boolean
  • Since: 2.0
  • Required: No
  • Expression: ${maven.compiler.showDeprecation}
  • Default: false

showWarnings:

Set to true to show compilation warnings.
  • Type: boolean
  • Since: 2.0
  • Required: No
  • Expression: ${maven.compiler.showWarnings}
  • Default: false

skipMultiThreadWarning:

(no description)
  • Type: boolean
  • Since: 2.5
  • Required: No
  • Expression: ${maven.compiler.skipMultiThreadWarning}
  • Default: ${false}

source:

The -source argument for the Java compiler.
  • Type: java.lang.String
  • Since: 2.0
  • Required: No
  • Expression: ${maven.compiler.source}
  • Default: 1.5

staleMillis:

Sets the granularity in milliseconds of the last modification date for testing whether a source needs recompilation.
  • Type: int
  • Since: 2.0
  • Required: No
  • Expression: ${lastModGranularityMs}
  • Default: 0

target:

The -target argument for the Java compiler.
  • Type: java.lang.String
  • Since: 2.0
  • Required: No
  • Expression: ${maven.compiler.target}
  • Default: 1.5

verbose:

Set to true to show messages about what the compiler is doing.
  • Type: boolean
  • Since: 2.0
  • Required: No
  • Expression: ${maven.compiler.verbose}
  • Default: false