Class TestCompilerMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.apache.maven.plugin.compiler.AbstractCompilerMojo
-
- org.apache.maven.plugin.compiler.TestCompilerMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="testCompile", defaultPhase=TEST_COMPILE, threadSafe=true, requiresDependencyResolution=TEST) public class TestCompilerMojo extends AbstractCompilerMojoCompiles application test 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.Collection<java.lang.String>classpathElementsprivate java.util.List<java.lang.String>compileSourceRootsThe source directories containing the test-source to be compiled.private java.lang.StringdebugFileNamewhen forking and debug activated the commandline used will be dumped in this fileprivate java.io.FilegeneratedTestSourcesDirectorySpecify where to place generated source files created by annotation processing.(package private) org.codehaus.plexus.languages.java.jpms.LocationManagerlocationManagerprivate java.util.Collection<java.lang.String>modulepathElementsprivate java.io.FileoutputDirectoryThe directory where compiled test classes go.private java.util.Map<java.lang.String,org.codehaus.plexus.languages.java.jpms.JavaModuleDescriptor>pathElementsprivate booleanskipSet this to 'true' to bypass compilation of test sources.private java.lang.StringtestCompilerArgumentSets the unformatted argument string to be passed to test compiler if fork is set to true.private java.util.Map<java.lang.String,java.lang.String>testCompilerArgumentsSets the arguments to be passed to test compiler (prepending a dash) if fork is set to true.private java.util.Set<java.lang.String>testExcludesA list of exclusion filters for the compiler.private java.util.Set<java.lang.String>testIncludesA list of inclusion filters for the compiler.private java.util.Set<java.lang.String>testIncrementalExcludesA list of exclusion filters for the incremental calculation.private java.util.List<java.lang.String>testPathprivate java.lang.StringtestReleasethe -release argument for the test Java compilerprivate java.lang.StringtestSourceThe -source argument for the test Java compiler.private java.lang.StringtestTargetThe -target argument for the test Java compiler.private booleanuseModulePathWhentrue, uses the module path when compiling with a release or target of 9+ and module-info.java or module-info.class is present.-
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 TestCompilerMojo()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexecute()protected java.util.List<java.lang.String>getClasspathElements()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()(package private) static booleanisOlderThanJDK9(java.lang.String version)protected booleanisTestCompile()protected voidpreparePaths(java.util.Set<java.io.File> sourceFiles)-
Methods inherited from class org.apache.maven.plugin.compiler.AbstractCompilerMojo
getBuildStartTime, getImplicit, getModuleDeclaration, getProject, getRequestThreadCount, getToolchain, isDependencyChanged, setRelease, setTarget
-
-
-
-
Field Detail
-
skip
@Parameter(property="maven.test.skip") private boolean skip
Set this to 'true' to bypass compilation of test sources. Its use is NOT RECOMMENDED, but quite convenient on occasion.
-
compileSourceRoots
@Parameter(defaultValue="${project.testCompileSourceRoots}", readonly=false, required=true) private java.util.List<java.lang.String> compileSourceRootsThe source directories containing the test-source to be compiled.
-
outputDirectory
@Parameter(defaultValue="${project.build.testOutputDirectory}", required=true, readonly=false) private java.io.File outputDirectoryThe directory where compiled test classes go.This parameter should only be modified in special cases. See the
CompilerMojo.outputDirectoryfor more information.- See Also:
CompilerMojo.outputDirectory
-
testIncludes
@Parameter private java.util.Set<java.lang.String> testIncludes
A list of inclusion filters for the compiler.
-
testExcludes
@Parameter private java.util.Set<java.lang.String> testExcludes
A list of exclusion filters for the compiler.
-
testIncrementalExcludes
@Parameter private java.util.Set<java.lang.String> testIncrementalExcludes
A list of exclusion filters for the incremental calculation.- Since:
- 3.11
-
testSource
@Parameter(property="maven.compiler.testSource") private java.lang.String testSource
The -source argument for the test Java compiler.- Since:
- 2.1
-
testTarget
@Parameter(property="maven.compiler.testTarget") private java.lang.String testTarget
The -target argument for the test Java compiler.- Since:
- 2.1
-
testRelease
@Parameter(property="maven.compiler.testRelease") private java.lang.String testRelease
the -release argument for the test Java compiler- Since:
- 3.6
-
testCompilerArguments
@Parameter private java.util.Map<java.lang.String,java.lang.String> testCompilerArguments
Sets the arguments to be passed to test 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.
- Since:
- 2.1
-
testCompilerArgument
@Parameter private java.lang.String testCompilerArgument
Sets the unformatted argument string to be passed to test compiler 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.
- Since:
- 2.1
-
generatedTestSourcesDirectory
@Parameter(defaultValue="${project.build.directory}/generated-test-sources/test-annotations") private java.io.File generatedTestSourcesDirectorySpecify where to place generated source files created by annotation processing. Only applies to JDK 1.6+
- Since:
- 2.2
-
useModulePath
@Parameter(defaultValue="true") private boolean useModulePath
When
true, uses the module path when compiling with a release or target of 9+ and module-info.java or module-info.class is present. Whenfalse, always uses the class path.- Since:
- 3.11
-
testPath
@Parameter(defaultValue="${project.testClasspathElements}", readonly=true) private java.util.List<java.lang.String> testPath
-
debugFileName
@Parameter(defaultValue="javac-test") private java.lang.String debugFileName
when forking and debug activated the commandline used will be dumped in this file- Since:
- 3.10.0
-
locationManager
final org.codehaus.plexus.languages.java.jpms.LocationManager locationManager
-
pathElements
private java.util.Map<java.lang.String,org.codehaus.plexus.languages.java.jpms.JavaModuleDescriptor> pathElements
-
classpathElements
private java.util.Collection<java.lang.String> classpathElements
-
modulepathElements
private java.util.Collection<java.lang.String> modulepathElements
-
-
Method Detail
-
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
-
getCompileSourceRoots
protected java.util.List<java.lang.String> getCompileSourceRoots()
- Specified by:
getCompileSourceRootsin classAbstractCompilerMojo
-
getPathElements
protected java.util.Map<java.lang.String,org.codehaus.plexus.languages.java.jpms.JavaModuleDescriptor> getPathElements()
- Specified by:
getPathElementsin 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
-
getOutputDirectory
protected java.io.File getOutputDirectory()
- Specified by:
getOutputDirectoryin classAbstractCompilerMojo
-
preparePaths
protected void preparePaths(java.util.Set<java.io.File> sourceFiles)
- Specified by:
preparePathsin classAbstractCompilerMojo
-
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
-
isOlderThanJDK9
static boolean isOlderThanJDK9(java.lang.String version)
-
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
-
isTestCompile
protected boolean isTestCompile()
- Overrides:
isTestCompilein classAbstractCompilerMojo
-
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
-
-