Class AbstractCompilerMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.apache.maven.plugin.compiler.AbstractCompilerMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
CompilerMojo,TestCompilerMojo
public abstract class AbstractCompilerMojo extends org.apache.maven.plugin.AbstractMojoTODO: At least one step could be optimized, currently the plugin will do two scans of all the source code if the compiler has to have the entire set of sources. This is currently the case for at least the C# compiler and most likely all the other .NET compilers too.- Since:
- 2.0
- Author:
- others, Trygve Laugstøl
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<java.lang.String>compilerArgsSets the arguments to be passed to the compiler.protected java.lang.StringcompilerArgumentSets the unformatted single argument string to be passed to the compiler.protected java.util.Map<java.lang.String,java.lang.String>compilerArgumentsDeprecated.usecompilerArgsinstead.protected static java.lang.StringPSprotected java.lang.StringreleaseThe-releaseargument for the Java compiler, supported since Java9protected java.lang.StringsourceThe-sourceargument for the Java compiler.protected java.lang.StringtargetThe-targetargument for the Java compiler.
-
Constructor Summary
Constructors Constructor Description AbstractCompilerMojo()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidexecute()protected java.util.DategetBuildStartTime()protected abstract java.util.List<java.lang.String>getClasspathElements()protected abstract java.lang.StringgetCompilerArgument()protected abstract java.util.Map<java.lang.String,java.lang.String>getCompilerArguments()protected abstract java.util.List<java.lang.String>getCompileSourceRoots()protected abstract java.lang.StringgetDebugFileName()protected abstract java.util.Set<java.lang.String>getExcludes()protected abstract java.io.FilegetGeneratedSourcesDirectory()protected abstract java.util.Set<java.lang.String>getIncludes()protected static intgetJavaMajorVersion(java.lang.String version)Returns the major Java version from its legacy or current string representation.protected java.util.Optional<java.nio.file.Path>getModuleDeclaration(java.util.Set<java.io.File> sourceFiles)protected abstract java.util.List<java.lang.String>getModulepathElements()protected abstract java.io.FilegetOutputDirectory()protected abstract java.util.Map<java.lang.String,org.codehaus.plexus.languages.java.jpms.JavaModuleDescriptor>getPathElements()protected org.apache.maven.project.MavenProjectgetProject()protected static java.util.List<java.io.File>getProjectOutputDirectories(java.io.File outputDirectory, int release)Returns existing multirelease JAR output directories through the given release in descending order.protected abstract java.lang.StringgetRelease()protected intgetRequestThreadCount()try to get thread count if a Maven 3 build, using reflection as the plugin must not be maven3 api dependentprotected abstract java.lang.StringgetSource()protected abstract org.codehaus.plexus.compiler.util.scan.SourceInclusionScannergetSourceInclusionScanner(int staleMillis)protected abstract org.codehaus.plexus.compiler.util.scan.SourceInclusionScannergetSourceInclusionScanner(java.lang.String inputFileEnding)protected abstract java.lang.StringgetTarget()protected org.apache.maven.toolchain.ToolchaingetToolchain()protected booleanisTestCompile()protected abstract voidpreparePaths(java.util.Set<java.io.File> sourceFiles)voidsetRelease(java.lang.String release)voidsetTarget(java.lang.String target)
-
-
-
Field Detail
-
PS
protected static final java.lang.String PS
-
source
@Parameter(property="maven.compiler.source", defaultValue="1.8") protected java.lang.String sourceThe
-sourceargument for the Java compiler.NOTE:
Since 3.8.0 the default value has changed from 1.5 to 1.6
Since 3.9.0 the default value has changed from 1.6 to 1.7
Since 3.11.0 the default value has changed from 1.7 to 1.8
- See Also:
- javac -source
-
target
@Parameter(property="maven.compiler.target", defaultValue="1.8") protected java.lang.String targetThe
-targetargument for the Java compiler.NOTE:
Since 3.8.0 the default value has changed from 1.5 to 1.6
Since 3.9.0 the default value has changed from 1.6 to 1.7
Since 3.11.0 the default value has changed from 1.7 to 1.8
- See Also:
- javac -target
-
release
@Parameter(property="maven.compiler.release") protected java.lang.String release
The-releaseargument for the Java compiler, supported since Java9- Since:
- 3.6
- See Also:
- javac -release
-
compilerArguments
@Parameter @Deprecated protected java.util.Map<java.lang.String,java.lang.String> compilerArguments
Deprecated.usecompilerArgsinstead.Sets the arguments to be passed to the compiler (prepending a dash).
This is because the list of valid arguments passed to a Java compiler varies based on the compiler version.
Note that
-Joptions are only passed through ifforkis set totrue.To pass
-Xmaxerrs 1000 -Xlint -Xlint:-path -Averbose=trueyou should include the following:<compilerArguments> <Xmaxerrs>1000</Xmaxerrs> <Xlint/> <Xlint:-path/> <Averbose>true</Averbose> </compilerArguments>
- Since:
- 2.0.1
-
compilerArgs
@Parameter protected java.util.List<java.lang.String> compilerArgs
Sets the arguments to be passed to the compiler.
Note that
Example:-Joptions are only passed through ifforkis set totrue.<compilerArgs> <arg>-Xmaxerrs</arg> <arg>1000</arg> <arg>-Xlint</arg> <arg>-J-Duser.language=en_us</arg> </compilerArgs>
- Since:
- 3.1
- See Also:
- javac -J
-
compilerArgument
@Parameter protected java.lang.String compilerArgument
Sets the unformatted single argument string to be passed to the compiler. To pass multiple arguments such as
-Xmaxerrs 1000(which are actually two arguments) you have to usecompilerArgs.This is because the list of valid arguments passed to a Java compiler varies based on the compiler version.
Note that
-Joptions are only passed through ifforkis set totrue.- See Also:
- javac -J
-
-
Method Detail
-
getSourceInclusionScanner
protected abstract org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner getSourceInclusionScanner(int staleMillis)
-
getSourceInclusionScanner
protected abstract org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner getSourceInclusionScanner(java.lang.String inputFileEnding)
-
getClasspathElements
protected abstract java.util.List<java.lang.String> getClasspathElements()
-
getModulepathElements
protected abstract java.util.List<java.lang.String> getModulepathElements()
-
getPathElements
protected abstract java.util.Map<java.lang.String,org.codehaus.plexus.languages.java.jpms.JavaModuleDescriptor> getPathElements()
-
getCompileSourceRoots
protected abstract java.util.List<java.lang.String> getCompileSourceRoots()
-
preparePaths
protected abstract void preparePaths(java.util.Set<java.io.File> sourceFiles)
-
getOutputDirectory
protected abstract java.io.File getOutputDirectory()
-
getSource
protected abstract java.lang.String getSource()
-
getTarget
protected abstract java.lang.String getTarget()
-
getRelease
protected abstract java.lang.String getRelease()
-
getCompilerArgument
protected abstract java.lang.String getCompilerArgument()
-
getCompilerArguments
protected abstract java.util.Map<java.lang.String,java.lang.String> getCompilerArguments()
-
getGeneratedSourcesDirectory
protected abstract java.io.File getGeneratedSourcesDirectory()
-
getDebugFileName
protected abstract java.lang.String getDebugFileName()
-
getProject
protected final org.apache.maven.project.MavenProject getProject()
-
getModuleDeclaration
protected final java.util.Optional<java.nio.file.Path> getModuleDeclaration(java.util.Set<java.io.File> sourceFiles)
-
getProjectOutputDirectories
protected static java.util.List<java.io.File> getProjectOutputDirectories(java.io.File outputDirectory, int release)Returns existing multirelease JAR output directories through the given release in descending order. The base output directory is returned last.
-
getJavaMajorVersion
protected static int getJavaMajorVersion(java.lang.String version)
Returns the major Java version from its legacy or current string representation.
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, CompilationFailureException- Throws:
org.apache.maven.plugin.MojoExecutionExceptionCompilationFailureException
-
isTestCompile
protected boolean isTestCompile()
-
getIncludes
protected abstract java.util.Set<java.lang.String> getIncludes()
-
getExcludes
protected abstract java.util.Set<java.lang.String> getExcludes()
-
getRequestThreadCount
protected int getRequestThreadCount()
try to get thread count if a Maven 3 build, using reflection as the plugin must not be maven3 api dependent- Returns:
- number of thread for this build or 1 if not multi-thread build
-
getBuildStartTime
protected java.util.Date getBuildStartTime()
-
getToolchain
protected final org.apache.maven.toolchain.Toolchain getToolchain()
-
setTarget
public void setTarget(java.lang.String target)
-
setRelease
public void setRelease(java.lang.String release)
-
-