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
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<DependencyCoordinate>annotationProcessorPathsClasspath elements to supply as annotation processor path.private booleanannotationProcessorPathsUseDepMgmtWhether to use the Maven dependency management section when resolving transitive dependencies of annotation processor paths.private java.lang.String[]annotationProcessorsNames of annotation processors to run.private org.apache.maven.artifact.handler.manager.ArtifactHandlerManagerartifactHandlerManagerArtifact handler manager.private java.io.FilebasedirThe directory to run the compiler from if fork is true.private java.io.FilebuildDirectoryThe target directory of the compiler if fork is true.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.private java.lang.StringcompilerIdThe compiler id of the compiler to use.private org.codehaus.plexus.compiler.manager.CompilerManagercompilerManagerPlexus compiler manager.private java.lang.StringcompilerReuseStrategyStrategy to re use javacc class created:reuseCreated(default): will reuse already created but in case of multi-threaded builds, each thread will have its own instancereuseSame: the same Javacc class will be used for each compilation even for multi-threaded buildalwaysNew: a new Javacc class will be created for each compilation Note this parameter value depends on the os/jdk you are using, but the default value should work on most of env.private java.lang.StringcompilerVersionDeprecated.This parameter is no longer evaluated by the underlying compilers, instead the actual version of thejavacbinary is automatically retrieved.private booleancreateMissingPackageInfoClassPackage info source files that only contain javadoc and no annotation on the package can lead to no class file being generated by the compiler.private booleandebugSet totrueto include debugging information in the compiled class files.private java.lang.StringdebuglevelKeyword list to be appended to the-gcommand-line switch.(package private) static java.lang.StringDEFAULT_SOURCE(package private) static java.lang.StringDEFAULT_TARGETprivate booleanenablePreviewSet totrueto enable preview language features of the java compilerprivate java.lang.StringencodingThe-encodingargument for the Java compiler.private java.lang.StringexecutableSets the executable of the compiler to use whenforkistrue.private booleanfailOnErrorIndicates whether the build will continue even if there are compilation errors.private booleanfailOnWarningIndicates whether the build will continue even if there are compilation warnings.private java.util.Set<java.lang.String>fileExtensionsFile extensions to check timestamp for incremental build.private booleanforceJavacCompilerUseDeprecated.UseforceLegacyJavacApiinsteadprivate booleanforceLegacyJavacApiThe underlying compiler now usesjavax.toolsAPI if available in your current JDK.private booleanforkAllows running the compiler in a separate process.private java.lang.StringimplicitKeyword to be appended to the-implicit:command-line switch.private static java.lang.StringINPUT_FILES_LST_FILENAMEprivate java.util.Map<java.lang.String,java.lang.String>jdkToolchainSpecify the requirements for this jdk toolchain for using a differentjavacthan the one of the JRE used by Maven.private java.lang.StringmaxmemSets the maximum size, in megabytes, of the memory allocation pool, ex.private java.lang.StringmeminitialInitial size, in megabytes, of the memory allocation pool, ex.private org.apache.maven.plugin.MojoExecutionmojoExecutionprivate booleanoptimizeDeprecated.This property is a no-op injavac.private java.lang.StringoutputFileNameSets the name of the output file when compiling a set of sources to a single file.private java.lang.StringoutputTimestampTimestamp for reproducible output archive entries, either formatted as ISO 8601yyyy-MM-dd'T'HH:mm:ssXXXor as an int representing seconds since the epoch (like SOURCE_DATE_EPOCH).private booleanparametersSet totrueto generate metadata for reflection on method parameters.private java.lang.StringprocSets whether annotation processing is performed or not.private org.apache.maven.project.MavenProjectprojectThe current project instance.protected static java.lang.StringPSprotected java.lang.StringreleaseThe-releaseargument for the Java compiler, supported since Java9private org.eclipse.aether.RepositorySystemrepositorySystemResolves the artifacts needed.private org.apache.maven.execution.MavenSessionsessionThe current build session instance.private booleanshowCompilationChangesprivate booleanshowDeprecationSets whether to show source locations where deprecated APIs are used.private booleanshowWarningsSet tofalseto disable warnings during compilation.private booleanskipMultiThreadWarningprotected java.lang.StringsourceThe-sourceargument for the Java compiler.private intstaleMillisSets the granularity in milliseconds of the last modification date for testing whether a source needs recompilation.protected java.lang.StringtargetThe-targetargument for the Java compiler.private booleantargetOrReleaseSetprivate org.apache.maven.toolchain.ToolchainManagertoolchainManagerprivate booleanuseIncrementalCompilationto enable/disable incremental compilation feature.private booleanverboseSet totrueto show messages about what the compiler is doing.
-
Constructor Summary
Constructors Constructor Description AbstractCompilerMojo()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private java.util.Set<java.io.File>computeStaleSources(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration, org.codehaus.plexus.compiler.Compiler compiler, org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner scanner)private java.util.Set<org.eclipse.aether.graph.Exclusion>convertToAetherExclusions(java.util.Set<DependencyExclusion> exclusions)private java.util.List<org.eclipse.aether.graph.Dependency>convertToDependencies(java.util.List<DependencyCoordinate> annotationProcessorPaths)private voidcreateMissingPackageInfoClasses(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration, org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping sourceMapping, java.util.Set<java.io.File> sources)voidexecute()private java.util.Optional<java.lang.String>findManagedVersion(DependencyCoordinate dependencyCoordinate, java.util.List<org.apache.maven.model.Dependency> managedDependencies)private byte[]generatePackage(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration, java.lang.String javaFile)private java.lang.StringgetAnnotationProcessorPathVersion(DependencyCoordinate annotationProcessorPath)protected java.util.DategetBuildStartTime()private java.util.Optional<java.time.Instant>getBuildStartTimeInstant()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()private java.util.Set<java.io.File>getCompileSources(org.codehaus.plexus.compiler.Compiler compiler, org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration)protected abstract java.lang.StringgetDebugFileName()protected abstract java.util.Set<java.lang.String>getExcludes()protected abstract java.io.FilegetGeneratedSourcesDirectory()(package private) java.lang.StringgetImplicit()protected abstract java.util.Set<java.lang.String>getIncludes()private java.util.List<org.eclipse.aether.graph.Dependency>getManagedDependenciesForAnnotationProcessorPaths()private java.lang.StringgetMavenCompilerPluginVersion()private java.lang.StringgetMemoryValue(java.lang.String setting)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()private intgetOpcode(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration)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()private java.util.List<org.apache.maven.model.Dependency>getProjectManagedDependencies()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)private org.codehaus.plexus.compiler.util.scan.mapping.SourceMappinggetSourceMapping(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration, org.codehaus.plexus.compiler.Compiler compiler)protected abstract java.lang.StringgetTarget()protected org.apache.maven.toolchain.ToolchaingetToolchain()private booleanhasInputFileTreeChanged(org.apache.maven.shared.incremental.IncrementalBuildHelper ibh, java.util.Set<java.io.File> inputFiles)private booleanhasNewFile(java.nio.file.Path file, java.time.Instant buildStartTime)protected booleanisDependencyChanged()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.private booleanisDigits(java.lang.String string)private booleanisSourceChanged(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration, org.codehaus.plexus.compiler.Compiler compiler)protected booleanisTestCompile()private voidpatchJdkModuleVersion(org.codehaus.plexus.compiler.CompilerResult compilerResult, java.util.Set<java.io.File> sources)JDK-8318913 workaround: Patch module-info.class to set the java release version for java/jdk modules.protected abstract voidpreparePaths(java.util.Set<java.io.File> sourceFiles)private static java.util.List<java.lang.String>removeEmptyCompileSourceRoots(java.util.List<java.lang.String> compileSourceRootsList)private java.util.List<java.lang.String>resolveProcessorPathEntries()voidsetRelease(java.lang.String release)voidsetTarget(java.lang.String target)private voidwriteConfig(org.apache.maven.shared.utils.logging.MessageBuilder mb)private voidwritePlugin(org.apache.maven.shared.utils.logging.MessageBuilder mb)
-
-
-
Field Detail
-
PS
protected static final java.lang.String PS
-
INPUT_FILES_LST_FILENAME
private static final java.lang.String INPUT_FILES_LST_FILENAME
- See Also:
- Constant Field Values
-
DEFAULT_SOURCE
static final java.lang.String DEFAULT_SOURCE
- See Also:
- Constant Field Values
-
DEFAULT_TARGET
static final java.lang.String DEFAULT_TARGET
- See Also:
- Constant Field Values
-
failOnError
@Parameter(property="maven.compiler.failOnError", defaultValue="true") private boolean failOnErrorIndicates whether the build will continue even if there are compilation errors.- Since:
- 2.0.2
-
failOnWarning
@Parameter(property="maven.compiler.failOnWarning", defaultValue="false") private boolean failOnWarningIndicates whether the build will continue even if there are compilation warnings.- Since:
- 3.6
-
debug
@Parameter(property="maven.compiler.debug", defaultValue="true") private boolean debugSet totrueto include debugging information in the compiled class files.- See Also:
- javac -g,
debuglevel
-
parameters
@Parameter(property="maven.compiler.parameters", defaultValue="false") private boolean parametersSet totrueto generate metadata for reflection on method parameters.- Since:
- 3.6.2
- See Also:
- javac -parameters
-
enablePreview
@Parameter(property="maven.compiler.enablePreview", defaultValue="false") private boolean enablePreviewSet totrueto enable preview language features of the java compiler- Since:
- 3.10.1
- See Also:
- javac --enable-preview
-
verbose
@Parameter(property="maven.compiler.verbose", defaultValue="false") private boolean verboseSet totrueto show messages about what the compiler is doing.- See Also:
- javac -verbose
-
showDeprecation
@Parameter(property="maven.compiler.showDeprecation", defaultValue="false") private boolean showDeprecationSets whether to show source locations where deprecated APIs are used.
-
optimize
@Deprecated @Parameter(property="maven.compiler.optimize", defaultValue="false") private boolean optimizeDeprecated.This property is a no-op injavac.Set totrueto optimize the compiled code using the compiler's optimization methods.
-
showWarnings
@Parameter(property="maven.compiler.showWarnings", defaultValue="true") private boolean showWarningsSet tofalseto disable warnings during compilation.
-
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
-
encoding
@Parameter(property="encoding", defaultValue="${project.build.sourceEncoding}") private java.lang.String encodingThe-encodingargument for the Java compiler.- Since:
- 2.1
- See Also:
- javac -encoding
-
staleMillis
@Parameter(property="lastModGranularityMs", defaultValue="0") private int staleMillisSets the granularity in milliseconds of the last modification date for testing whether a source needs recompilation.
-
compilerId
@Parameter(property="maven.compiler.compilerId", defaultValue="javac") private java.lang.String compilerIdThe compiler id of the compiler to use. See this guide for more information.
-
compilerVersion
@Deprecated @Parameter(property="maven.compiler.compilerVersion") private java.lang.String compilerVersion
Deprecated.This parameter is no longer evaluated by the underlying compilers, instead the actual version of thejavacbinary is automatically retrieved.Version of the compiler to use, ex. "1.3", "1.5", ifforkis set totrue.
-
fork
@Parameter(property="maven.compiler.fork", defaultValue="false") private boolean forkAllows running the compiler in a separate process. Iffalseit uses the built in compiler, while iftrueit will use an executable.
-
meminitial
@Parameter(property="maven.compiler.meminitial") private java.lang.String meminitial
Initial size, in megabytes, of the memory allocation pool, ex. "64", "64m" ifforkis set totrue.- Since:
- 2.0.1
-
maxmem
@Parameter(property="maven.compiler.maxmem") private java.lang.String maxmem
Sets the maximum size, in megabytes, of the memory allocation pool, ex. "128", "128m" ifforkis set totrue.- Since:
- 2.0.1
-
executable
@Parameter(property="maven.compiler.executable") private java.lang.String executable
Sets the executable of the compiler to use whenforkistrue.
-
proc
@Parameter(property="maven.compiler.proc") private java.lang.String proc
Sets whether annotation processing is performed or not. Only applies to JDK 1.6+ If not set, both compilation and annotation processing are performed at the same time.
Allowed values are:
none- no annotation processing is performed.only- only annotation processing is done, no compilation.full- annotation processing and compilation.
fullis the default. Starting with JDK 21, this option must be set explicitly.- Since:
- 2.2
- See Also:
- javac -proc, javac Annotation Processing
-
annotationProcessors
@Parameter private java.lang.String[] annotationProcessors
Names of annotation processors to run. Only applies to JDK 1.6+ If not set, the default annotation processors discovery process applies.
- Since:
- 2.2
- See Also:
- javac -processor, javac Annotation Processing
-
annotationProcessorPaths
@Parameter private java.util.List<DependencyCoordinate> annotationProcessorPaths
Classpath elements to supply as annotation processor path. If specified, the compiler will detect annotation processors only in those classpath elements. If omitted, the default classpath is used to detect annotation processors. The detection itself depends on the configuration of
annotationProcessors.Each classpath element is specified using their Maven coordinates (groupId, artifactId, version, classifier, type). Transitive dependencies are added automatically. Exclusions are supported as well. Example:
<configuration> <annotationProcessorPaths> <path> <groupId>org.sample</groupId> <artifactId>sample-annotation-processor</artifactId> <version>1.2.3</version> <!-- Optional - taken from dependency management if not specified --> <!-- Optionally exclude transitive dependencies --> <exclusions> <exclusion> <groupId>org.sample</groupId> <artifactId>sample-dependency</artifactId> </exclusion> </exclusions> </path> <!-- ... more ... --> </annotationProcessorPaths> </configuration>Note: Exclusions are supported from version 3.11.0.- Since:
- 3.5
- See Also:
- javac -processorpath, javac Annotation Processing
-
annotationProcessorPathsUseDepMgmt
@Parameter(defaultValue="false") private boolean annotationProcessorPathsUseDepMgmt
Whether to use the Maven dependency management section when resolving transitive dependencies of annotation processor paths.
This flag does not enable / disable the ability to resolve the version of annotation processor paths from dependency management section. It only influences the resolution of transitive dependencies of those top-level paths.
- Since:
- 3.12.0
-
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
-
outputFileName
@Parameter private java.lang.String outputFileName
Sets the name of the output file when compiling a set of sources to a single file. expression="${project.build.finalName}"
-
debuglevel
@Parameter(property="maven.compiler.debuglevel") private java.lang.String debuglevel
Keyword list to be appended to the-gcommand-line switch. Legal values are none or a comma-separated list of the following keywords:lines,vars, andsource. If debug level is not specified, by default, nothing will be appended to-g. Ifdebugis not turned on, this attribute will be ignored.- Since:
- 2.1
- See Also:
- javac -G:[lines,vars,source]
-
implicit
@Parameter(property="maven.compiler.implicit") private java.lang.String implicit
Keyword to be appended to the-implicit:command-line switch.- Since:
- 3.10.2
- See Also:
- javac -implicit
-
toolchainManager
@Component private org.apache.maven.toolchain.ToolchainManager toolchainManager
-
jdkToolchain
@Parameter private java.util.Map<java.lang.String,java.lang.String> jdkToolchain
Specify the requirements for this jdk toolchain for using a different
(see Guide to Toolchains for more info)javacthan the one of the JRE used by Maven. This overrules the toolchain selected by the maven-toolchain-plugin.<configuration> <jdkToolchain> <version>11</version> </jdkToolchain> ... </configuration> <configuration> <jdkToolchain> <version>1.8</version> <vendor>zulu</vendor> </jdkToolchain> ... </configuration>note: requires at least Maven 3.3.1- Since:
- 3.6
-
basedir
@Parameter(defaultValue="${basedir}", required=true, readonly=true) private java.io.File basedirThe directory to run the compiler from if fork is true.
-
buildDirectory
@Parameter(defaultValue="${project.build.directory}", required=true, readonly=true) private java.io.File buildDirectoryThe target directory of the compiler if fork is true.
-
compilerManager
@Component private org.codehaus.plexus.compiler.manager.CompilerManager compilerManager
Plexus compiler manager.
-
session
@Parameter(defaultValue="${session}", readonly=true, required=true) private org.apache.maven.execution.MavenSession sessionThe current build session instance. This is used for toolchain manager API calls.
-
project
@Parameter(defaultValue="${project}", readonly=true, required=true) private org.apache.maven.project.MavenProject projectThe current project instance. This is used for propagating generated-sources paths as compile/testCompile source roots.
-
compilerReuseStrategy
@Parameter(defaultValue="${reuseCreated}", property="maven.compiler.compilerReuseStrategy") private java.lang.String compilerReuseStrategyStrategy to re use javacc class created:reuseCreated(default): will reuse already created but in case of multi-threaded builds, each thread will have its own instancereuseSame: the same Javacc class will be used for each compilation even for multi-threaded buildalwaysNew: a new Javacc class will be created for each compilation
- Since:
- 2.5
-
skipMultiThreadWarning
@Parameter(defaultValue="false", property="maven.compiler.skipMultiThreadWarning") private boolean skipMultiThreadWarning- Since:
- 2.5
-
forceJavacCompilerUse
@Deprecated @Parameter(defaultValue="false", property="maven.compiler.forceJavacCompilerUse") private boolean forceJavacCompilerUseDeprecated.UseforceLegacyJavacApiinsteadLegacy parameter name offorceLegacyJavacApi. Only considered ifforceLegacyJavacApiis not set orfalse.- Since:
- 3.0
-
forceLegacyJavacApi
@Parameter(defaultValue="false", property="maven.compiler.forceLegacyJavacApi") private boolean forceLegacyJavacApiThe underlying compiler now usesjavax.toolsAPI if available in your current JDK. Set this totrueto always use the legacycom.sun.tools.javacAPI instead.This only has an effect for
compilerIdbeingjavacandforkbeingfalse.- Since:
- 3.13
-
mojoExecution
@Parameter(defaultValue="${mojoExecution}", readonly=true, required=true) private org.apache.maven.plugin.MojoExecution mojoExecution- Since:
- 3.0 needed for storing the status for the incremental build support.
-
fileExtensions
@Parameter(defaultValue="class,jar") private java.util.Set<java.lang.String> fileExtensions
File extensions to check timestamp for incremental build.- Since:
- 3.1
-
useIncrementalCompilation
@Parameter(defaultValue="true", property="maven.compiler.useIncrementalCompilation") private boolean useIncrementalCompilationto enable/disable incremental compilation feature.
This leads to two different modes depending on the underlying compiler. The default javac compiler does the following:
- true (default) in this mode the compiler plugin determines whether any JAR files the current module depends on have changed in the current build run; or any source file was added, removed or changed since the last compilation. If this is the case, the compiler plugin recompiles all sources.
- false (not recommended) this only compiles source files which are newer than their corresponding class files, namely which have changed since the last compilation. This does not recompile other classes which use the changed class, potentially leaving them with references to methods that no longer exist, leading to errors at runtime.
- Since:
- 3.1
-
createMissingPackageInfoClass
@Parameter(defaultValue="true", property="maven.compiler.createMissingPackageInfoClass") private boolean createMissingPackageInfoClassPackage info source files that only contain javadoc and no annotation on the package can lead to no class file being generated by the compiler. This causes a file miss on the next compilations and forces an unnecessary recompilation. The default value oftruecauses an empty class file to be generated. This behavior can be changed by setting this parameter tofalse.- Since:
- 3.10
-
showCompilationChanges
@Parameter(defaultValue="false", property="maven.compiler.showCompilationChanges") private boolean showCompilationChanges
-
outputTimestamp
@Parameter(defaultValue="${project.build.outputTimestamp}") private java.lang.String outputTimestampTimestamp for reproducible output archive entries, either formatted as ISO 8601yyyy-MM-dd'T'HH:mm:ssXXXor as an int representing seconds since the epoch (like SOURCE_DATE_EPOCH).- Since:
- 3.12.0
-
repositorySystem
@Component private org.eclipse.aether.RepositorySystem repositorySystem
Resolves the artifacts needed.
-
artifactHandlerManager
@Component private org.apache.maven.artifact.handler.manager.ArtifactHandlerManager artifactHandlerManager
Artifact handler manager.
-
targetOrReleaseSet
private boolean targetOrReleaseSet
-
-
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)
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, CompilationFailureException- Throws:
org.apache.maven.plugin.MojoExecutionExceptionCompilationFailureException
-
createMissingPackageInfoClasses
private void createMissingPackageInfoClasses(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration, org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping sourceMapping, java.util.Set<java.io.File> sources) throws org.codehaus.plexus.compiler.util.scan.InclusionScanException, java.io.IOException- Throws:
org.codehaus.plexus.compiler.util.scan.InclusionScanExceptionjava.io.IOException
-
generatePackage
private byte[] generatePackage(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration, java.lang.String javaFile)
-
getOpcode
private int getOpcode(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration)
-
isTestCompile
protected boolean isTestCompile()
-
getCompileSources
private java.util.Set<java.io.File> getCompileSources(org.codehaus.plexus.compiler.Compiler compiler, org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration) throws org.apache.maven.plugin.MojoExecutionException, org.codehaus.plexus.compiler.CompilerException- Returns:
- all source files for the compiler
- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.codehaus.plexus.compiler.CompilerException
-
getIncludes
protected abstract java.util.Set<java.lang.String> getIncludes()
-
getExcludes
protected abstract java.util.Set<java.lang.String> getExcludes()
-
isSourceChanged
private boolean isSourceChanged(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration, org.codehaus.plexus.compiler.Compiler compiler)- Parameters:
compilerConfiguration-compiler-- Returns:
trueif at least a single source file is newer than it's class file
-
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()
-
getBuildStartTimeInstant
private java.util.Optional<java.time.Instant> getBuildStartTimeInstant()
-
getMemoryValue
private java.lang.String getMemoryValue(java.lang.String setting)
-
getToolchain
protected final org.apache.maven.toolchain.Toolchain getToolchain()
-
isDigits
private boolean isDigits(java.lang.String string)
-
computeStaleSources
private java.util.Set<java.io.File> computeStaleSources(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration, org.codehaus.plexus.compiler.Compiler compiler, org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner scanner) throws org.apache.maven.plugin.MojoExecutionException, org.codehaus.plexus.compiler.CompilerException- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.codehaus.plexus.compiler.CompilerException
-
getSourceMapping
private org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping getSourceMapping(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration, org.codehaus.plexus.compiler.Compiler compiler) throws org.codehaus.plexus.compiler.CompilerException, org.apache.maven.plugin.MojoExecutionException- Throws:
org.codehaus.plexus.compiler.CompilerExceptionorg.apache.maven.plugin.MojoExecutionException
-
removeEmptyCompileSourceRoots
private static java.util.List<java.lang.String> removeEmptyCompileSourceRoots(java.util.List<java.lang.String> compileSourceRootsList)
-
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:
trueif at least one single dependency has changed.
-
hasNewFile
private boolean hasNewFile(java.nio.file.Path file, java.time.Instant buildStartTime)- Parameters:
file- entry to checkbuildStartTime- time build start- Returns:
- if any changes occurred
-
resolveProcessorPathEntries
private java.util.List<java.lang.String> resolveProcessorPathEntries() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
convertToDependencies
private java.util.List<org.eclipse.aether.graph.Dependency> convertToDependencies(java.util.List<DependencyCoordinate> annotationProcessorPaths) throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getAnnotationProcessorPathVersion
private java.lang.String getAnnotationProcessorPathVersion(DependencyCoordinate annotationProcessorPath) throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
findManagedVersion
private java.util.Optional<java.lang.String> findManagedVersion(DependencyCoordinate dependencyCoordinate, java.util.List<org.apache.maven.model.Dependency> managedDependencies)
-
getManagedDependenciesForAnnotationProcessorPaths
private java.util.List<org.eclipse.aether.graph.Dependency> getManagedDependenciesForAnnotationProcessorPaths()
-
getProjectManagedDependencies
private java.util.List<org.apache.maven.model.Dependency> getProjectManagedDependencies()
-
convertToAetherExclusions
private java.util.Set<org.eclipse.aether.graph.Exclusion> convertToAetherExclusions(java.util.Set<DependencyExclusion> exclusions)
-
writePlugin
private void writePlugin(org.apache.maven.shared.utils.logging.MessageBuilder mb)
-
writeConfig
private void writeConfig(org.apache.maven.shared.utils.logging.MessageBuilder mb)
-
getMavenCompilerPluginVersion
private java.lang.String getMavenCompilerPluginVersion()
-
hasInputFileTreeChanged
private boolean hasInputFileTreeChanged(org.apache.maven.shared.incremental.IncrementalBuildHelper ibh, java.util.Set<java.io.File> inputFiles)
-
setTarget
public void setTarget(java.lang.String target)
-
setRelease
public void setRelease(java.lang.String release)
-
getImplicit
final java.lang.String getImplicit()
-
patchJdkModuleVersion
private void patchJdkModuleVersion(org.codehaus.plexus.compiler.CompilerResult compilerResult, java.util.Set<java.io.File> sources) throws org.apache.maven.plugin.MojoExecutionExceptionJDK-8318913 workaround: Patch module-info.class to set the java release version for java/jdk modules.- Parameters:
compilerResult- should succeed.sources- the list of the source files to check for the "module-info.java"- Throws:
org.apache.maven.plugin.MojoExecutionException- See Also:
- MCOMPILER-542, JDK-8318913
-
-