Package org.apache.maven.plugin.compiler
Class CompilerMojo
java.lang.Object
org.apache.maven.plugin.compiler.AbstractCompilerMojo
org.apache.maven.plugin.compiler.CompilerMojo
- All Implemented Interfaces:
org.apache.maven.api.plugin.Mojo
@Mojo(name="compile",
defaultPhase="compile")
public class CompilerMojo
extends AbstractCompilerMojo
Compiles application sources.
By default uses the javac compiler
of the JDK used to execute Maven. This can be overwritten through Toolchains
or parameter
AbstractCompilerMojo.compilerId
.- Since:
- 2.0
- Author:
- Jason van Zyl
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionThe source directories containing the sources to be compiled.protected String
When bothAbstractCompilerMojo.fork
andAbstractCompilerMojo.debug
are enabled the commandline arguments used will be dumped to this file.A list of exclusion filters for the compiler.protected Path
Specify where to place generated source files created by annotation processing.A list of inclusion filters for the compiler.A list of exclusion filters for the incremental calculation.protected boolean
When set totrue
, the classes will be placed inMETA-INF/versions/${release}
The release value must be set, otherwise the plugin will fail.protected Path
The directory for compiled classes.protected org.apache.maven.api.Artifact
Projects main artifact.protected boolean
Set this totrue
to bypass compilation of main sources.Fields inherited from class org.apache.maven.plugin.compiler.AbstractCompilerMojo
annotationProcessorPaths, annotationProcessorPathsUseDepMgmt, annotationProcessors, artifactManager, basedir, buildDirectory, compilerArgs, compilerArgument, compilerId, compilerManager, compilerReuseStrategy, compilerVersion, createMissingPackageInfoClass, debug, enablePreview, encoding, executable, failOnError, failOnWarning, fileExtensions, forceLegacyJavacApi, fork, implicit, jdkToolchain, logger, maxmem, meminitial, messageBuilderFactory, mojoStatusPath, optimize, outputTimestamp, parameters, proc, project, projectManager, PS, release, session, showCompilationChanges, showDeprecation, showWarnings, skipMultiThreadWarning, source, staleMillis, target, toolchainManager, useIncrementalCompilation, verbose
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
execute()
protected String
protected String
protected Path
protected Path
protected String
protected String
protected org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner
getSourceInclusionScanner
(int staleMillis) protected org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner
getSourceInclusionScanner
(String inputFileEnding) protected String
protected void
preparePaths
(Set<Path> sourceFiles) Methods inherited from class org.apache.maven.plugin.compiler.AbstractCompilerMojo
getBuildStartTime, getLog, getModuleDeclaration, getProject, getRequestThreadCount, getToolchain, isDependencyChanged, isTestCompile, setRelease, setTarget
-
Field Details
-
compileSourceRoots
The source directories containing the sources to be compiled. -
projectArtifact
@Parameter(defaultValue="${project.mainArtifact}", readonly=true, required=true) protected org.apache.maven.api.Artifact projectArtifactProjects main artifact. -
outputDirectory
@Parameter(defaultValue="${project.build.outputDirectory}", required=true, readonly=true) protected Path outputDirectoryThe directory for compiled classes. -
includes
A list of inclusion filters for the compiler. -
excludes
A list of exclusion filters for the compiler. -
incrementalExcludes
A list of exclusion filters for the incremental calculation.- Since:
- 3.11
-
generatedSourcesDirectory
@Parameter(defaultValue="${project.build.directory}/generated-sources/annotations") protected Path generatedSourcesDirectorySpecify where to place generated source files created by annotation processing. Only applies to JDK 1.6+
- Since:
- 2.2
-
skipMain
@Parameter(property="maven.main.skip") protected boolean skipMainSet this totrue
to bypass compilation of main sources. Its use is NOT RECOMMENDED, but quite convenient on occasion. -
compilePath
-
multiReleaseOutput
@Parameter protected boolean multiReleaseOutputWhen set to
Note: A jar is only a multirelease jar iftrue
, the classes will be placed inMETA-INF/versions/${release}
The release value must be set, otherwise the plugin will fail.META-INF/MANIFEST.MF
containsMulti-Release: true
. You need to set this by configuring the maven-jar-plugin. This implies that you cannot test a multirelease jar using the outputDirectory.- Since:
- 3.7.1
-
debugFileName
When bothAbstractCompilerMojo.fork
andAbstractCompilerMojo.debug
are enabled the commandline arguments used will be dumped to this file.- Since:
- 3.10.0
-
-
Constructor Details
-
CompilerMojo
public CompilerMojo()
-
-
Method Details
-
getCompileSourceRoots
- Specified by:
getCompileSourceRoots
in classAbstractCompilerMojo
-
getClasspathElements
- Specified by:
getClasspathElements
in classAbstractCompilerMojo
-
getModulepathElements
- Specified by:
getModulepathElements
in classAbstractCompilerMojo
-
getPathElements
protected Map<String,org.codehaus.plexus.languages.java.jpms.JavaModuleDescriptor> getPathElements()- Specified by:
getPathElements
in classAbstractCompilerMojo
-
getOutputDirectory
- Specified by:
getOutputDirectory
in classAbstractCompilerMojo
-
execute
public void execute() throws org.apache.maven.api.plugin.MojoException- Specified by:
execute
in interfaceorg.apache.maven.api.plugin.Mojo
- Overrides:
execute
in classAbstractCompilerMojo
- Throws:
org.apache.maven.api.plugin.MojoException
-
getIncludes
- Specified by:
getIncludes
in classAbstractCompilerMojo
-
getExcludes
- Specified by:
getExcludes
in classAbstractCompilerMojo
-
preparePaths
- Specified by:
preparePaths
in classAbstractCompilerMojo
-
getSourceInclusionScanner
protected org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner getSourceInclusionScanner(int staleMillis) - Specified by:
getSourceInclusionScanner
in classAbstractCompilerMojo
-
getSourceInclusionScanner
protected org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner getSourceInclusionScanner(String inputFileEnding) - Specified by:
getSourceInclusionScanner
in classAbstractCompilerMojo
-
getSource
- Specified by:
getSource
in classAbstractCompilerMojo
-
getTarget
- Specified by:
getTarget
in classAbstractCompilerMojo
-
getRelease
- Specified by:
getRelease
in classAbstractCompilerMojo
-
getCompilerArgument
- Specified by:
getCompilerArgument
in classAbstractCompilerMojo
-
getGeneratedSourcesDirectory
- Specified by:
getGeneratedSourcesDirectory
in classAbstractCompilerMojo
-
getDebugFileName
- Specified by:
getDebugFileName
in classAbstractCompilerMojo
-