Class AbstractCompilerMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.apache.maven.plugin.compiler.AbstractCompilerMojo
-
- All Implemented Interfaces:
ContextEnabled
,Mojo
- Direct Known Subclasses:
CompilerMojo
,TestCompilerMojo
public abstract class AbstractCompilerMojo extends AbstractMojo
TODO: 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 List<String>
compilerArgs
Sets the arguments to be passed to the compiler.protected String
compilerArgument
Sets the unformatted single argument string to be passed to the compiler.protected Map<String,String>
compilerArguments
Deprecated.usecompilerArgs
instead.protected static String
PS
protected String
release
The -release argument for the Java compiler, supported since Java9protected String
source
The -source argument for the Java compiler.protected String
target
The -target argument for the Java compiler.
-
Constructor Summary
Constructors Constructor Description AbstractCompilerMojo()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected org.codehaus.plexus.compiler.CompilerResult
convertToCompilerResult(List<org.codehaus.plexus.compiler.CompilerError> compilerErrors)
void
execute()
protected Date
getBuildStartTime()
protected abstract List<String>
getClasspathElements()
protected abstract String
getCompilerArgument()
protected abstract Map<String,String>
getCompilerArguments()
protected abstract List<String>
getCompileSourceRoots()
protected abstract String
getDebugFileName()
protected abstract File
getGeneratedSourcesDirectory()
protected abstract List<String>
getModulepathElements()
protected abstract File
getOutputDirectory()
protected abstract Map<String,JavaModuleDescriptor>
getPathElements()
protected MavenProject
getProject()
protected abstract String
getRelease()
protected int
getRequestThreadCount()
try to get thread count if a Maven 3 build, using reflection as the plugin must not be maven3 api dependentprotected abstract String
getSource()
protected abstract org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner
getSourceInclusionScanner(int staleMillis)
protected abstract org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner
getSourceInclusionScanner(String inputFileEnding)
protected abstract String
getTarget()
protected Toolchain
getToolchain()
protected boolean
isDependencyChanged()
We just compare the timestamps of all local dependency files (inter-module dependency classpath) and the own generated classes and if we got a file which is >= the build-started timestamp, then we caught a file which got changed during this build.protected boolean
isTestCompile()
protected abstract void
preparePaths(Set<File> sourceFiles)
void
setRelease(String release)
void
setTarget(String target)
-
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
-
-
-
Field Detail
-
PS
protected static final String PS
-
source
@Parameter(property="maven.compiler.source", defaultValue="1.7") protected String source
The -source argument 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
-
target
@Parameter(property="maven.compiler.target", defaultValue="1.7") protected String target
The -target argument 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
-
release
@Parameter(property="maven.compiler.release") protected String release
The -release argument for the Java compiler, supported since Java9- Since:
- 3.6
-
compilerArguments
@Parameter @Deprecated protected Map<String,String> compilerArguments
Deprecated.usecompilerArgs
instead.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
-J
options are only passed through iffork
is set totrue
.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>
- Since:
- 2.0.1
-
compilerArgs
@Parameter protected List<String> compilerArgs
Sets the arguments to be passed to the compiler.
Note that
Example:-J
options are only passed through iffork
is set totrue
.<compilerArgs> <arg>-Xmaxerrs</arg> <arg>1000</arg> <arg>-Xlint</arg> <arg>-J-Duser.language=en_us</arg> </compilerArgs>
- Since:
- 3.1
-
compilerArgument
@Parameter protected 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 usecompilerArguments
.This is because the list of valid arguments passed to a Java compiler varies based on the compiler version.
Note that
-J
options are only passed through iffork
is set totrue
.
-
-
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(String inputFileEnding)
-
getPathElements
protected abstract Map<String,JavaModuleDescriptor> getPathElements()
-
getOutputDirectory
protected abstract File getOutputDirectory()
-
getSource
protected abstract String getSource()
-
getTarget
protected abstract String getTarget()
-
getRelease
protected abstract String getRelease()
-
getCompilerArgument
protected abstract String getCompilerArgument()
-
getGeneratedSourcesDirectory
protected abstract File getGeneratedSourcesDirectory()
-
getDebugFileName
protected abstract String getDebugFileName()
-
getProject
protected final MavenProject getProject()
-
execute
public void execute() throws MojoExecutionException, CompilationFailureException
-
isTestCompile
protected boolean isTestCompile()
-
convertToCompilerResult
protected org.codehaus.plexus.compiler.CompilerResult convertToCompilerResult(List<org.codehaus.plexus.compiler.CompilerError> compilerErrors)
-
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 Date getBuildStartTime()
-
getToolchain
protected final Toolchain getToolchain()
-
isDependencyChanged
protected boolean isDependencyChanged()
We just compare the timestamps of all local dependency files (inter-module dependency classpath) and the own generated classes and if we got a file which is >= the build-started timestamp, then we caught a file which got changed during this build.- Returns:
true
if at least one single dependency has changed.
-
setTarget
public void setTarget(String target)
-
setRelease
public void setRelease(String release)
-
-