Package org.apache.maven.plugin.compiler
Class CompilerMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.apache.maven.plugin.compiler.AbstractCompilerMojo
-
- org.apache.maven.plugin.compiler.CompilerMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="compile", defaultPhase=COMPILE, threadSafe=true, requiresDependencyResolution=COMPILE) public class CompilerMojo extends AbstractCompilerMojoCompiles application sources. By default uses the javac compiler of the JDK used to execute Maven. This can be overwritten through Toolchains or parameterAbstractCompilerMojo.compilerId.- Since:
- 2.0
- See Also:
- javac Command
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<java.lang.String>classpathElementsprivate java.util.List<java.lang.String>compilePathprivate java.util.List<java.lang.String>compileSourceRootsThe source directories containing the sources to be compiled.private java.lang.StringdebugFileNameWhen bothAbstractCompilerMojo.forkandAbstractCompilerMojo.debugare enabled the commandline arguments used will be dumped to this file.private java.util.Set<java.lang.String>excludesA list of exclusion filters for the compiler.private java.io.FilegeneratedSourcesDirectorySpecify where to place generated source files created by annotation processing.private java.util.Set<java.lang.String>includesA list of inclusion filters for the compiler.private java.util.Set<java.lang.String>incrementalExcludesA list of exclusion filters for the incremental calculation.(package private) org.codehaus.plexus.languages.java.jpms.LocationManagerlocationManagerprivate java.util.List<java.lang.String>modulepathElementsprivate java.lang.StringmoduleVersionThe--module-versionargument for the Java compiler.private booleanmultiReleaseOutputWhen set totrue, the classes will be placed inMETA-INF/versions/${release}The release value must be set, otherwise the plugin will fail.private java.io.FileoutputDirectoryThe directory for compiled classes.private java.util.Map<java.lang.String,org.codehaus.plexus.languages.java.jpms.JavaModuleDescriptor>pathElementsprivate org.apache.maven.artifact.ArtifactprojectArtifactProjects main artifact.private booleanskipMainSet this totrueto bypass compilation of main sources.-
Fields inherited from class org.apache.maven.plugin.compiler.AbstractCompilerMojo
compilerArgs, compilerArgument, compilerArguments, DEFAULT_SOURCE, DEFAULT_TARGET, PS, release, source, target
-
-
Constructor Summary
Constructors Constructor Description CompilerMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voiddetectFilenameBasedAutomodules(org.codehaus.plexus.languages.java.jpms.ResolvePathsResult<java.io.File> resolvePathsResult, org.codehaus.plexus.languages.java.jpms.JavaModuleDescriptor moduleDescriptor)voidexecute()protected java.util.List<java.lang.String>getClasspathElements()private java.util.List<java.io.File>getCompileClasspathElements(org.apache.maven.project.MavenProject project)protected java.lang.StringgetCompilerArgument()protected java.util.Map<java.lang.String,java.lang.String>getCompilerArguments()protected java.util.List<java.lang.String>getCompileSourceRoots()protected java.lang.StringgetDebugFileName()protected java.util.Set<java.lang.String>getExcludes()protected java.io.FilegetGeneratedSourcesDirectory()protected java.util.Set<java.lang.String>getIncludes()protected java.util.List<java.lang.String>getModulepathElements()protected java.io.FilegetOutputDirectory()protected java.util.Map<java.lang.String,org.codehaus.plexus.languages.java.jpms.JavaModuleDescriptor>getPathElements()protected java.lang.StringgetRelease()protected java.lang.StringgetSource()protected org.codehaus.plexus.compiler.util.scan.SourceInclusionScannergetSourceInclusionScanner(int staleMillis)protected org.codehaus.plexus.compiler.util.scan.SourceInclusionScannergetSourceInclusionScanner(java.lang.String inputFileEnding)protected java.lang.StringgetTarget()protected voidpreparePaths(java.util.Set<java.io.File> sourceFiles)private voidwriteBoxedWarning(java.lang.String message)-
Methods inherited from class org.apache.maven.plugin.compiler.AbstractCompilerMojo
getBuildStartTime, getImplicit, getModuleDeclaration, getProject, getRequestThreadCount, getToolchain, isDependencyChanged, isTestCompile, setRelease, setTarget
-
-
-
-
Field Detail
-
compileSourceRoots
@Parameter(defaultValue="${project.compileSourceRoots}", readonly=false, required=true) private java.util.List<java.lang.String> compileSourceRootsThe source directories containing the sources to be compiled.
-
outputDirectory
@Parameter(property="maven.compiler.outputDirectory", defaultValue="${project.build.outputDirectory}", required=true, readonly=false) private java.io.File outputDirectoryThe directory for compiled classes.This parameter should only be modified in special cases. One example is creating a multi-release jar with a lower bytecode level (i.e. setting it to
${project.build.outputDirectory}/META-INF/versions/21or similar) in an additional execution.When the required bytecode level is available though an installed JDK or toolchain, it is recommended to use the
<release>property in conjunction with the ${multiReleaseOutput} parameter instead.
-
projectArtifact
@Parameter(defaultValue="${project.artifact}", readonly=true, required=true) private org.apache.maven.artifact.Artifact projectArtifactProjects main artifact.
-
includes
@Parameter private java.util.Set<java.lang.String> includes
A list of inclusion filters for the compiler.
-
excludes
@Parameter private java.util.Set<java.lang.String> excludes
A list of exclusion filters for the compiler.
-
incrementalExcludes
@Parameter private java.util.Set<java.lang.String> incrementalExcludes
A list of exclusion filters for the incremental calculation.- Since:
- 3.11
-
generatedSourcesDirectory
@Parameter(defaultValue="${project.build.directory}/generated-sources/annotations") private java.io.File 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") private boolean skipMain
Set this totrueto bypass compilation of main sources. Its use is NOT RECOMMENDED, but quite convenient on occasion.
-
compilePath
@Parameter(defaultValue="${project.compileClasspathElements}", readonly=true, required=true) private java.util.List<java.lang.String> compilePath
-
multiReleaseOutput
@Parameter private boolean multiReleaseOutput
When 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.MFcontainsMulti-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
@Parameter(defaultValue="javac") private java.lang.String debugFileName
When bothAbstractCompilerMojo.forkandAbstractCompilerMojo.debugare enabled the commandline arguments used will be dumped to this file.- Since:
- 3.10.0
-
moduleVersion
@Parameter(property="maven.compiler.moduleVersion", defaultValue="${project.version}") private java.lang.String moduleVersionThe--module-versionargument for the Java compiler. This is ignored if not applicable, e.g., in non-modular projects.- Since:
- 3.14.0
- See Also:
- javac --module-version
-
locationManager
final org.codehaus.plexus.languages.java.jpms.LocationManager locationManager
-
classpathElements
private java.util.List<java.lang.String> classpathElements
-
modulepathElements
private java.util.List<java.lang.String> modulepathElements
-
pathElements
private java.util.Map<java.lang.String,org.codehaus.plexus.languages.java.jpms.JavaModuleDescriptor> pathElements
-
-
Method Detail
-
getCompileSourceRoots
protected java.util.List<java.lang.String> getCompileSourceRoots()
- Specified by:
getCompileSourceRootsin classAbstractCompilerMojo
-
getClasspathElements
protected java.util.List<java.lang.String> getClasspathElements()
- Specified by:
getClasspathElementsin classAbstractCompilerMojo
-
getModulepathElements
protected java.util.List<java.lang.String> getModulepathElements()
- Specified by:
getModulepathElementsin classAbstractCompilerMojo
-
getPathElements
protected java.util.Map<java.lang.String,org.codehaus.plexus.languages.java.jpms.JavaModuleDescriptor> getPathElements()
- Specified by:
getPathElementsin classAbstractCompilerMojo
-
getOutputDirectory
protected java.io.File getOutputDirectory()
- Specified by:
getOutputDirectoryin classAbstractCompilerMojo
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, CompilationFailureException- Specified by:
executein interfaceorg.apache.maven.plugin.Mojo- Overrides:
executein classAbstractCompilerMojo- Throws:
org.apache.maven.plugin.MojoExecutionExceptionCompilationFailureException
-
getIncludes
protected java.util.Set<java.lang.String> getIncludes()
- Specified by:
getIncludesin classAbstractCompilerMojo
-
getExcludes
protected java.util.Set<java.lang.String> getExcludes()
- Specified by:
getExcludesin classAbstractCompilerMojo
-
preparePaths
protected void preparePaths(java.util.Set<java.io.File> sourceFiles)
- Specified by:
preparePathsin classAbstractCompilerMojo
-
detectFilenameBasedAutomodules
private void detectFilenameBasedAutomodules(org.codehaus.plexus.languages.java.jpms.ResolvePathsResult<java.io.File> resolvePathsResult, org.codehaus.plexus.languages.java.jpms.JavaModuleDescriptor moduleDescriptor)
-
getCompileClasspathElements
private java.util.List<java.io.File> getCompileClasspathElements(org.apache.maven.project.MavenProject project)
-
getSourceInclusionScanner
protected org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner getSourceInclusionScanner(int staleMillis)
- Specified by:
getSourceInclusionScannerin classAbstractCompilerMojo
-
getSourceInclusionScanner
protected org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner getSourceInclusionScanner(java.lang.String inputFileEnding)
- Specified by:
getSourceInclusionScannerin classAbstractCompilerMojo
-
getSource
protected java.lang.String getSource()
- Specified by:
getSourcein classAbstractCompilerMojo
-
getTarget
protected java.lang.String getTarget()
- Specified by:
getTargetin classAbstractCompilerMojo
-
getRelease
protected java.lang.String getRelease()
- Specified by:
getReleasein classAbstractCompilerMojo
-
getCompilerArgument
protected java.lang.String getCompilerArgument()
- Specified by:
getCompilerArgumentin classAbstractCompilerMojo
-
getCompilerArguments
protected java.util.Map<java.lang.String,java.lang.String> getCompilerArguments()
- Specified by:
getCompilerArgumentsin classAbstractCompilerMojo
-
getGeneratedSourcesDirectory
protected java.io.File getGeneratedSourcesDirectory()
- Specified by:
getGeneratedSourcesDirectoryin classAbstractCompilerMojo
-
getDebugFileName
protected java.lang.String getDebugFileName()
- Specified by:
getDebugFileNamein classAbstractCompilerMojo
-
writeBoxedWarning
private void writeBoxedWarning(java.lang.String message)
-
-