diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPluginConfigurationDomExtender.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPluginConfigurationDomExtender.java index 3d61400736a0..0329301b7d3c 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPluginConfigurationDomExtender.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPluginConfigurationDomExtender.java @@ -1,6 +1,7 @@ // Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.idea.maven.dom; +import com.intellij.openapi.util.IntellijInternalApi; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.NlsSafe; import com.intellij.openapi.util.text.StringUtil; @@ -16,6 +17,7 @@ import com.intellij.util.xml.XmlName; import com.intellij.util.xml.reflect.DomExtender; import com.intellij.util.xml.reflect.DomExtension; import com.intellij.util.xml.reflect.DomExtensionsRegistrar; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.maven.dom.converters.MavenDomConvertersRegistry; @@ -29,18 +31,30 @@ import org.jetbrains.idea.maven.dom.plugin.MavenDomPluginModel; import java.lang.annotation.Annotation; import java.util.*; +import java.util.function.Function; public final class MavenPluginConfigurationDomExtender extends DomExtender { public static final Key PLUGIN_PARAMETER_KEY = Key.create("MavenPluginConfigurationDomExtender.PLUGIN_PARAMETER_KEY"); private static final Set COLLECTIONS_TYPE_NAMES = Set.of("java.util.Collection", CommonClassNames.JAVA_UTIL_SET, - CommonClassNames.JAVA_UTIL_LIST, - "java.util.ArrayList", "java.util.HashSet", - CommonClassNames.JAVA_UTIL_LINKED_LIST); + CommonClassNames.JAVA_UTIL_LIST, + "java.util.ArrayList", "java.util.HashSet", + CommonClassNames.JAVA_UTIL_LINKED_LIST); + private final Function<@NotNull MavenDomConfiguration, @Nullable MavenDomPluginModel> myRetriever; + + @IntellijInternalApi + @ApiStatus.Internal + public MavenPluginConfigurationDomExtender(Function<@NotNull MavenDomConfiguration, @Nullable MavenDomPluginModel> modelRetriever) { + myRetriever = modelRetriever; + } + + public MavenPluginConfigurationDomExtender() { + this(MavenPluginDomUtil::getMavenPluginModel); + } @Override public void registerExtensions(@NotNull MavenDomConfiguration config, @NotNull DomExtensionsRegistrar r) { - MavenDomPluginModel pluginModel = MavenPluginDomUtil.getMavenPluginModel(config); + MavenDomPluginModel pluginModel = myRetriever.apply(config); if (pluginModel == null) { r.registerCustomChildrenExtension(MavenDomConfigurationParameter.class); return; @@ -68,6 +82,7 @@ public final class MavenPluginConfigurationDomExtender extends DomExtender collectParameters(MavenDomPluginModel pluginModel, MavenDomConfiguration config) { List selectedGoals = null; @@ -94,12 +109,13 @@ public final class MavenPluginConfigurationDomExtender extends DomExtender d2.getRequiringLevel(); } - private static void fillParameterData(String name, ParameterData data, MavenDomMojo mojo) { - XmlTag config = mojo.getConfiguration().getXmlTag(); - if (config == null) return; + private static Map getMojoConfigurationAsMap(MavenDomMojo mojo) { + if (mojo == null) return Collections.emptyMap(); + var config = mojo.getConfiguration().getXmlTag(); + if (config == null) return Collections.emptyMap(); + Map result = new HashMap<>(); for (XmlTag each : config.getSubTags()) { - if (!name.equals(each.getName())) continue; - data.defaultValue = each.getAttributeValue("default-value"); - data.expression = each.getValue().getTrimmedText(); + result.put(each.getName(), each); + } + return result; + } + + private static void fillParameterData(String name, ParameterData data, Map mojoConfig) { + XmlTag configForMaven3 = mojoConfig.get(name); + if (configForMaven3 != null) { + data.defaultValue = configForMaven3.getAttributeValue("default-value"); + data.expression = configForMaven3.getValue().getTrimmedText(); + } + else { + data.defaultValue = data.parameter.getDefaultValue().getStringValue(); + data.expression = data.parameter.getExpression().getStringValue(); } } + private static void registerPluginParameter(boolean isInPluginManagement, DomExtensionsRegistrar r, final ParameterData parameter) { String paramName = parameter.parameter.getName().getStringValue(); String alias = parameter.parameter.getAlias().getStringValue(); @@ -141,7 +171,10 @@ public final class MavenPluginConfigurationDomExtender extends DomExtender annotationType() { - return Required.class; + return Required.class; } }); } @@ -243,5 +277,4 @@ public final class MavenPluginConfigurationDomExtender extends DomExtender getDescription(); + /** + * since maven-plugin-tools 4.0 + */ + @NotNull + GenericDomValue getDefaultValue(); + + /** + * since maven-plugin-tools 4.0 + */ + @NotNull + GenericDomValue getExpression(); + GenericDomValue getRequired(); } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPluginConfigurationDomExtenderTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPluginConfigurationDomExtenderTest.kt new file mode 100644 index 000000000000..c46ad2963db1 --- /dev/null +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPluginConfigurationDomExtenderTest.kt @@ -0,0 +1,191 @@ +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package org.jetbrains.idea.maven.dom + +import com.intellij.maven.testFramework.MavenDomTestCase +import com.intellij.openapi.application.readAction +import com.intellij.openapi.util.Key +import com.intellij.openapi.util.io.StreamUtil +import com.intellij.openapi.vfs.VirtualFile +import com.intellij.psi.PsiElement +import com.intellij.util.ResourceUtil +import com.intellij.util.xml.Converter +import com.intellij.util.xml.DomElement +import com.intellij.util.xml.Required +import com.intellij.util.xml.XmlName +import com.intellij.util.xml.reflect.CustomDomChildrenDescription +import com.intellij.util.xml.reflect.DomExtender +import com.intellij.util.xml.reflect.DomExtension +import com.intellij.util.xml.reflect.DomExtensionsRegistrar +import kotlinx.coroutines.runBlocking +import org.jetbrains.idea.maven.dom.plugin.MavenDomPluginModel +import org.junit.Test +import java.lang.reflect.Type +import java.util.function.Supplier + +class MavenPluginConfigurationDomExtenderTest : MavenDomTestCase() { + + @Test + fun testShouldCorrectlyAddTagsForMaven3Plugin() = runBlocking { + assumeMaven3() + doTestWith(pluginModelFileName = "compiler-3-14-1.xml") + } + + @Test + fun testShouldCorrectlyAddTagsForMaven4Plugin() = runBlocking { + assumeMaven4() + doTestWith(pluginModelFileName = "compiler-4-0-beta3.xml") + } + + private suspend fun doTestWith(pluginModelFileName: String) { + importProjectAsync(""" + test + test + 1 + + + + org.apache.maven.plugins + maven-compiler-plugin + + + -some-arg + + + + + + """ + ) + + val pluginFile = createFromFile(pluginModelFileName, "plugin-test/$pluginModelFileName") + readAction { + val dom = MavenDomUtil.getMavenDomProjectModel(project, projectPom)!! + val compilerConfiguration = dom + .build + .plugins + .plugins + .single { it.artifactId.stringValue == "maven-compiler-plugin" } + .configuration + + val pluginFileModel = MavenDomUtil.getMavenDomModel(project, pluginFile, MavenDomPluginModel::class.java) + val extender = MavenPluginConfigurationDomExtender { + pluginFileModel + } + val registeredExtensions = ArrayList() + val registrar = MyRegistrar(registeredExtensions) + + extender.registerExtensions(compilerConfiguration, registrar) + val basedir2ForTest = registeredExtensions.singleOrNull() { it.xmlName.localName == "basedir2ForTest" } + assertNotNull(basedir2ForTest) + assertEquals(1, basedir2ForTest!!.customAnnotations.size) + assertTrue(basedir2ForTest.customAnnotations[0] is Required) + + val basedir = registeredExtensions.singleOrNull() { it.xmlName.localName == "basedir" } + assertNotNull(basedir) + assertEmpty(basedir!!.customAnnotations) + } + } + + private fun createFromFile(file: String, resourceName: String): VirtualFile { + val result = ResourceUtil.getResourceAsStream(this::class.java.classLoader, "org/jetbrains/maven/", resourceName).use { + StreamUtil.readBytes(it).toString(Charsets.UTF_8) + } + return createProjectSubFile(file, result) + } + +} + + +private class MyDomExtention(val xmlName: XmlName, private val type: Type) : DomExtension { + var declaringElement: DomElement? = null + var declaringElementFinder: Supplier? = null + var declaringPsiElement: PsiElement? = null + var converter: Converter<*>? = null + var isSoft: Boolean = false + val customAnnotations: MutableList = ArrayList() + val userData: MutableMap, Any?> = HashMap() + val extenders: MutableList> = ArrayList() + + override fun getType(): Type { + return type + } + + override fun setDeclaringElement(declaringElement: DomElement): DomExtension { + this.declaringElement = declaringElement + return this + } + + override fun setDeclaringDomElement(declarationFinder: Supplier): DomExtension { + this.declaringElementFinder = declarationFinder + return this + } + + override fun setDeclaringElement(declaringElement: PsiElement): DomExtension { + this.declaringPsiElement = declaringElement + return this + } + + override fun setConverter(converter: Converter<*>): DomExtension { + this.converter = converter + return this + } + + override fun setConverter(converter: Converter<*>, soft: Boolean): DomExtension { + this.converter = converter + this.isSoft = soft + return this + } + + override fun addCustomAnnotation(anno: Annotation): DomExtension { + customAnnotations.add(anno) + return this + } + + override fun putUserData(key: Key?, value: T?) { + if (key != null) { + @Suppress("UNCHECKED_CAST") + (userData as MutableMap, T?>)[key] = value + } + } + + override fun addExtender(extender: DomExtender<*>?): DomExtension { + if (extender != null) { + extenders.add(extender) + } + return this + } + +} + +private class MyRegistrar(val registeredExtensions: MutableList) : DomExtensionsRegistrar { + override fun registerFixedNumberChildExtension(name: XmlName, type: Type): DomExtension { + return MyDomExtention(name, type).also { registeredExtensions.add(it) } + } + + override fun registerCollectionChildrenExtension(name: XmlName, type: Type): DomExtension { + return MyDomExtention(name, type).also { registeredExtensions.add(it) } + } + + override fun registerGenericAttributeValueChildExtension(name: XmlName, parameterType: Type?): DomExtension { + TODO() + } + + override fun registerAttributeChildExtension(name: XmlName, type: Type): DomExtension { + TODO() + } + + override fun registerCustomChildrenExtension(type: Type): DomExtension { + TODO() + } + + override fun registerCustomChildrenExtension(type: Type, descriptor: CustomDomChildrenDescription.TagNameDescriptor): DomExtension { + TODO() + } + + override fun registerCustomChildrenExtension(type: Type, attributeDescriptor: CustomDomChildrenDescription.AttributeDescriptor): DomExtension { + TODO() + } + +} + + diff --git a/plugins/maven/src/test/resources/org/jetbrains/maven/plugin-test/compiler-3-14-1.xml b/plugins/maven/src/test/resources/org/jetbrains/maven/plugin-test/compiler-3-14-1.xml new file mode 100644 index 000000000000..cdeb52cc5d73 --- /dev/null +++ b/plugins/maven/src/test/resources/org/jetbrains/maven/plugin-test/compiler-3-14-1.xml @@ -0,0 +1,1423 @@ + + + + + + Apache Maven Compiler Plugin + The Compiler Plugin is used to compile the sources of your project. + org.apache.maven.plugins + maven-compiler-plugin + 3.14.1 + compiler + false + false + true + 1.8 + 3.6.3 + + + compile + Compiles application sources. By default uses the javac <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html> compiler of the JDK used to execute Maven. This can be overwritten through Toolchains <https://maven.apache.org/guides/mini/guide-using-toolchains.html> or parameter compilerId. + See also: javac Command <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html> + compile + false + true + false + false + false + true + compile + org.apache.maven.plugin.compiler.CompilerMojo + java + per-lookup + once-per-session + 2.0 + true + + + annotationProcessorPaths + java.util.List + 3.5 + false + true + + 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. + See also: javac -processorpath <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-processor-path>, javac Annotation Processing <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#annotation-processing> + + + annotationProcessorPathsUseDepMgmt + boolean + 3.12.0 + false + true + + 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. + + + + annotationProcessors + java.lang.String[] + 2.2 + false + true + + Names of annotation processors to run. Only applies to JDK 1.6+ If not set, the default annotation processors discovery process applies. + + See also: javac -processor <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-processor>, javac Annotation Processing <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#annotation-processing> + + + basedir + java.io.File + true + false + The directory to run the compiler from if fork is true. + + + basedir2ForTest + java.io.File + true + false + The directory to run the compiler from if fork is true. + + + buildDirectory + java.io.File + true + false + The target directory of the compiler if fork is true. + + + compilePath + java.util.List + true + false + + + + compileSourceRoots + java.util.List + true + true + The source directories containing the sources to be compiled. + + + compilerArgs + java.util.List + 3.1 + false + true + + Sets the arguments to be passed to the compiler. + + Note that -J options are only passed through if fork is set to true. + Example: <compilerArgs> <arg>-Xmaxerrs</arg> <arg>1000</arg> <arg>-Xlint</arg> <arg>-J-Duser.language=en_us</arg> </compilerArgs> + See also: javac -J <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-J> + + + compilerArgument + java.lang.String + false + true + + 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 use compilerArgs. + + 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 if fork is set to true. + + See also: javac -J <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-J> + + + compilerArguments + java.util.Map + 2.0.1 + use compilerArgs instead. + false + true + + 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 if fork is set to true. + + 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> + + + compilerId + java.lang.String + false + true + The compiler id of the compiler to use. See this guide for more information. + + + compilerReuseStrategy + java.lang.String + 2.5 + false + true + Strategy 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 instance + * reuseSame: the same Javacc class will be used for each compilation even for multi-threaded build + * alwaysNew: 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. + + + compilerVersion + java.lang.String + This parameter is no longer evaluated by the underlying compilers, instead the actual version of the javac binary is automatically retrieved. + false + true + Version of the compiler to use, ex. "1.3", "1.5", if fork is set to true. + + + createMissingPackageInfoClass + boolean + 3.10 + false + true + Package 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 of true causes an empty class file to be generated. This behavior can be changed by setting this parameter to false. + + + debug + boolean + false + true + Set to true to include debugging information in the compiled class files. + See also: javac -g <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-g>, debuglevel + + + debugFileName + java.lang.String + 3.10.0 + false + true + When both fork and debug are enabled the commandline arguments used will be dumped to this file. + + + debuglevel + java.lang.String + 2.1 + false + true + Keyword list to be appended to the -g command-line switch. Legal values are none or a comma-separated list of the following keywords: lines, vars, and source. If debug level is not specified, by default, nothing will be appended to -g. If debug is not turned on, this attribute will be ignored. + See also: javac -G:[lines,vars,source] <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-g-custom> + + + enablePreview + boolean + 3.10.1 + false + true + Set to true to enable preview language features of the java compiler + See also: javac --enable-preview <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-enable-preview> + + + encoding + java.lang.String + 2.1 + false + true + The -encoding argument for the Java compiler. + See also: javac -encoding <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-encoding> + + + excludes + java.util.Set + false + true + A list of exclusion filters for the compiler. + + + executable + java.lang.String + false + true + Sets the executable of the compiler to use when fork is true. + + + failOnError + boolean + 2.0.2 + false + true + Indicates whether the build will continue even if there are compilation errors. + + + failOnWarning + boolean + 3.6 + false + true + Indicates whether the build will continue even if there are compilation warnings. + + + fileExtensions + java.util.Set + 3.1 + false + true + File extensions to check timestamp for incremental build. + + + forceJavacCompilerUse + boolean + 3.0 + Use forceLegacyJavacApi instead + false + true + Legacy parameter name of forceLegacyJavacApi. Only considered if forceLegacyJavacApi is not set or false. + + + forceLegacyJavacApi + boolean + 3.13 + false + true + The underlying compiler now uses javax.tools API <https://docs.oracle.com/en/java/javase/17/docs/api/java.compiler/javax/tools/package-summary.html> if available in your current JDK. Set this to true to always use the legacy com.sun.tools.javac API <https://docs.oracle.com/en/java/javase/17/docs/api/jdk.compiler/com/sun/tools/javac/package-summary.html> instead. + This only has an effect for compilerId being javac and fork being false. + + + + fork + boolean + false + true + Allows running the compiler in a separate process. If false it uses the built in compiler, while if true it will use an executable. + + + generatedSourcesDirectory + java.io.File + 2.2 + false + true + Specify where to place generated source files created by annotation processing. Only applies to JDK 1.6+ + + + implicit + java.lang.String + 3.10.2 + false + true + Keyword to be appended to the -implicit: command-line switch. + See also: javac -implicit <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-implicit> + + + includes + java.util.Set + false + true + A list of inclusion filters for the compiler. + + + incrementalExcludes + java.util.Set + 3.11 + false + true + A list of exclusion filters for the incremental calculation. + + + jdkToolchain + java.util.Map + 3.6 + false + true + + Specify the requirements for this jdk toolchain for using a different javac than the one of the JRE used by Maven. This overrules the toolchain selected by the maven-toolchain-plugin <https://maven.apache.org/plugins/maven-toolchains-plugin/>. + (see Guide to Toolchains <https://maven.apache.org/guides/mini/guide-using-toolchains.html> for more info) <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 + + + maxmem + java.lang.String + 2.0.1 + false + true + Sets the maximum size, in megabytes, of the memory allocation pool, ex. "128", "128m" if fork is set to true. + + + meminitial + java.lang.String + 2.0.1 + false + true + Initial size, in megabytes, of the memory allocation pool, ex. "64", "64m" if fork is set to true. + + + moduleVersion + java.lang.String + 3.14.0 + false + true + The --module-version argument for the Java compiler. This is ignored if not applicable, e.g., in non-modular projects. + See also: javac --module-version <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-module-version> + + + mojoExecution + org.apache.maven.plugin.MojoExecution + 3.0 needed for storing the status for the incremental build support. + true + false + + + + multiReleaseOutput + boolean + 3.7.1 + false + true + + When set to true, the classes will be placed in META-INF/versions/${release} The release value must be set, otherwise the plugin will fail. + Note: A jar is only a multirelease jar if META-INF/MANIFEST.MF contains Multi-Release: true. You need to set this by configuring the maven-jar-plugin <https://maven.apache.org/plugins/maven-jar-plugin/examples/manifest-customization.html>. This implies that you cannot test a multirelease jar using the outputDirectory. + + + optimize + boolean + This property is a no-op in javac. + false + true + Set to true to optimize the compiled code using the compiler's optimization methods. + + + outputDirectory + java.io.File + true + true + The 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/21} or 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. + + + + outputFileName + java.lang.String + false + true + Sets the name of the output file when compiling a set of sources to a single file. + + expression="${project.build.finalName}" + + + outputTimestamp + java.lang.String + 3.12.0 + false + true + Timestamp for reproducible output archive entries, either formatted as ISO 8601 yyyy-MM-dd'T'HH:mm:ssXXX or as an int representing seconds since the epoch (like SOURCE_DATE_EPOCH <https://reproducible-builds.org/docs/source-date-epoch/>). + + + parameters + boolean + 3.6.2 + false + true + Set to true to generate metadata for reflection on method parameters. + See also: javac -parameters <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-parameters> + + + proc + java.lang.String + 2.2 + false + true + + 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. full is the default. Starting with JDK 21, this option must be set explicitly. + See also: javac -proc <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-proc>, javac Annotation Processing <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#annotation-processing> + + + project + org.apache.maven.project.MavenProject + true + false + The current project instance. This is used for propagating generated-sources paths as compile/testCompile source roots. + + + projectArtifact + org.apache.maven.artifact.Artifact + true + false + Projects main artifact. + + + release + java.lang.String + 3.6 + false + true + The -release argument for the Java compiler, supported since Java9 + See also: javac -release <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-release> + + + session + org.apache.maven.execution.MavenSession + true + false + The current build session instance. This is used for toolchain manager API calls. + + + showCompilationChanges + boolean + false + true + + + + showDeprecation + boolean + false + true + Sets whether to show source locations where deprecated APIs are used. + + + showWarnings + boolean + false + true + Set to false to disable warnings during compilation. + + + skipMain + boolean + false + true + Set this to true to bypass compilation of main sources. Its use is NOT RECOMMENDED, but quite convenient on occasion. + + + skipMultiThreadWarning + boolean + 2.5 + false + true + + + + source + java.lang.String + false + true + + 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 + + Since 3.11.0 the default value has changed from 1.7 to 1.8 + + See also: javac -source <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-source> + + + staleMillis + int + false + true + Sets the granularity in milliseconds of the last modification date for testing whether a source needs recompilation. + + + target + java.lang.String + false + true + + 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 + + Since 3.11.0 the default value has changed from 1.7 to 1.8 + + See also: javac -target <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-target> + + + useIncrementalCompilation + boolean + 3.1 + false + true + + to 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. + + + useModuleVersion + boolean + 3.15.0 + false + true + Use the --module-version argument for the Java compiler. This is ignored if not applicable, e.g., in non-modular projects. + See also: javac --module-version <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-module-version> + + + verbose + boolean + false + true + Set to true to show messages about what the compiler is doing. + See also: javac -verbose <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-verbose> + + + + + + + + + ${maven.compiler.compilerId} + ${maven.compiler.compilerReuseStrategy} + ${maven.compiler.compilerVersion} + ${maven.compiler.createMissingPackageInfoClass} + ${maven.compiler.debug} + + ${maven.compiler.debuglevel} + ${maven.compiler.enablePreview} + ${encoding} + ${maven.compiler.executable} + ${maven.compiler.failOnError} + ${maven.compiler.failOnWarning} + + ${maven.compiler.forceJavacCompilerUse} + ${maven.compiler.forceLegacyJavacApi} + ${maven.compiler.fork} + + ${maven.compiler.implicit} + ${maven.compiler.maxmem} + ${maven.compiler.meminitial} + ${maven.compiler.moduleVersion} + + ${maven.compiler.optimize} + ${maven.compiler.outputDirectory} + + ${maven.compiler.parameters} + ${maven.compiler.proc} + + + ${maven.compiler.release} + + ${maven.compiler.showCompilationChanges} + ${maven.compiler.showDeprecation} + ${maven.compiler.showWarnings} + ${maven.main.skip} + ${maven.compiler.skipMultiThreadWarning} + ${maven.compiler.source} + ${lastModGranularityMs} + ${maven.compiler.target} + ${maven.compiler.useIncrementalCompilation} + ${maven.compiler.useModuleVersion} + ${maven.compiler.verbose} + + + + org.apache.maven.artifact.handler.manager.ArtifactHandlerManager + artifactHandlerManager + + + org.codehaus.plexus.compiler.manager.CompilerManager + compilerManager + + + org.eclipse.aether.RepositorySystem + repositorySystem + + + org.apache.maven.toolchain.ToolchainManager + toolchainManager + + + + + help + Display help information on maven-compiler-plugin. + Call mvn compiler:help -Ddetail=true -Dgoal=<goal-name> to display parameter details. + false + false + false + false + false + true + org.apache.maven.plugins.maven_compiler_plugin.HelpMojo + java + per-lookup + once-per-session + true + + + detail + boolean + false + true + If true, display all settable properties for each goal. + + + goal + java.lang.String + false + true + The name of the goal for which to show help. If unspecified, all goals will be displayed. + + + indentSize + int + false + true + The number of spaces per indentation level, should be positive. + + + lineLength + int + false + true + The maximum length of a display line, should be positive. + + + + ${detail} + ${goal} + ${indentSize} + ${lineLength} + + + + testCompile + Compiles application test sources. By default uses the javac <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html> compiler of the JDK used to execute Maven. This can be overwritten through Toolchains <https://maven.apache.org/guides/mini/guide-using-toolchains.html> or parameter compilerId. + See also: javac Command <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html> + test + false + true + false + false + false + true + test-compile + org.apache.maven.plugin.compiler.TestCompilerMojo + java + per-lookup + once-per-session + 2.0 + true + + + annotationProcessorPaths + java.util.List + 3.5 + false + true + + 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. + See also: javac -processorpath <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-processor-path>, javac Annotation Processing <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#annotation-processing> + + + annotationProcessorPathsUseDepMgmt + boolean + 3.12.0 + false + true + + 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. + + + + annotationProcessors + java.lang.String[] + 2.2 + false + true + + Names of annotation processors to run. Only applies to JDK 1.6+ If not set, the default annotation processors discovery process applies. + + See also: javac -processor <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-processor>, javac Annotation Processing <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#annotation-processing> + + + basedir + java.io.File + true + false + The directory to run the compiler from if fork is true. + + + buildDirectory + java.io.File + true + false + The target directory of the compiler if fork is true. + + + compileSourceRoots + java.util.List + true + true + The source directories containing the test-source to be compiled. + + + compilerArgs + java.util.List + 3.1 + false + true + + Sets the arguments to be passed to the compiler. + + Note that -J options are only passed through if fork is set to true. + Example: <compilerArgs> <arg>-Xmaxerrs</arg> <arg>1000</arg> <arg>-Xlint</arg> <arg>-J-Duser.language=en_us</arg> </compilerArgs> + See also: javac -J <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-J> + + + compilerArgument + java.lang.String + false + true + + 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 use compilerArgs. + + 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 if fork is set to true. + + See also: javac -J <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-J> + + + compilerArguments + java.util.Map + 2.0.1 + use compilerArgs instead. + false + true + + 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 if fork is set to true. + + 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> + + + compilerId + java.lang.String + false + true + The compiler id of the compiler to use. See this guide for more information. + + + compilerReuseStrategy + java.lang.String + 2.5 + false + true + Strategy 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 instance + * reuseSame: the same Javacc class will be used for each compilation even for multi-threaded build + * alwaysNew: 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. + + + compilerVersion + java.lang.String + This parameter is no longer evaluated by the underlying compilers, instead the actual version of the javac binary is automatically retrieved. + false + true + Version of the compiler to use, ex. "1.3", "1.5", if fork is set to true. + + + createMissingPackageInfoClass + boolean + 3.10 + false + true + Package 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 of true causes an empty class file to be generated. This behavior can be changed by setting this parameter to false. + + + debug + boolean + false + true + Set to true to include debugging information in the compiled class files. + See also: javac -g <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-g>, debuglevel + + + debugFileName + java.lang.String + 3.10.0 + false + true + when forking and debug activated the commandline used will be dumped in this file + + + debuglevel + java.lang.String + 2.1 + false + true + Keyword list to be appended to the -g command-line switch. Legal values are none or a comma-separated list of the following keywords: lines, vars, and source. If debug level is not specified, by default, nothing will be appended to -g. If debug is not turned on, this attribute will be ignored. + See also: javac -G:[lines,vars,source] <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-g-custom> + + + enablePreview + boolean + 3.10.1 + false + true + Set to true to enable preview language features of the java compiler + See also: javac --enable-preview <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-enable-preview> + + + encoding + java.lang.String + 2.1 + false + true + The -encoding argument for the Java compiler. + See also: javac -encoding <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-encoding> + + + executable + java.lang.String + false + true + Sets the executable of the compiler to use when fork is true. + + + failOnError + boolean + 2.0.2 + false + true + Indicates whether the build will continue even if there are compilation errors. + + + failOnWarning + boolean + 3.6 + false + true + Indicates whether the build will continue even if there are compilation warnings. + + + fileExtensions + java.util.Set + 3.1 + false + true + File extensions to check timestamp for incremental build. + + + forceJavacCompilerUse + boolean + 3.0 + Use forceLegacyJavacApi instead + false + true + Legacy parameter name of forceLegacyJavacApi. Only considered if forceLegacyJavacApi is not set or false. + + + forceLegacyJavacApi + boolean + 3.13 + false + true + The underlying compiler now uses javax.tools API <https://docs.oracle.com/en/java/javase/17/docs/api/java.compiler/javax/tools/package-summary.html> if available in your current JDK. Set this to true to always use the legacy com.sun.tools.javac API <https://docs.oracle.com/en/java/javase/17/docs/api/jdk.compiler/com/sun/tools/javac/package-summary.html> instead. + This only has an effect for compilerId being javac and fork being false. + + + + fork + boolean + false + true + Allows running the compiler in a separate process. If false it uses the built in compiler, while if true it will use an executable. + + + generatedTestSourcesDirectory + java.io.File + 2.2 + false + true + + Specify where to place generated source files created by annotation processing. Only applies to JDK 1.6+ + + + + implicit + java.lang.String + 3.10.2 + false + true + Keyword to be appended to the -implicit: command-line switch. + See also: javac -implicit <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-implicit> + + + jdkToolchain + java.util.Map + 3.6 + false + true + + Specify the requirements for this jdk toolchain for using a different javac than the one of the JRE used by Maven. This overrules the toolchain selected by the maven-toolchain-plugin <https://maven.apache.org/plugins/maven-toolchains-plugin/>. + (see Guide to Toolchains <https://maven.apache.org/guides/mini/guide-using-toolchains.html> for more info) <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 + + + maxmem + java.lang.String + 2.0.1 + false + true + Sets the maximum size, in megabytes, of the memory allocation pool, ex. "128", "128m" if fork is set to true. + + + meminitial + java.lang.String + 2.0.1 + false + true + Initial size, in megabytes, of the memory allocation pool, ex. "64", "64m" if fork is set to true. + + + mojoExecution + org.apache.maven.plugin.MojoExecution + 3.0 needed for storing the status for the incremental build support. + true + false + + + + optimize + boolean + This property is a no-op in javac. + false + true + Set to true to optimize the compiled code using the compiler's optimization methods. + + + outputDirectory + java.io.File + true + true + The directory where compiled test classes go. + This parameter should only be modified in special cases. See the CompilerMojo.outputDirectory for more information. + + See also: CompilerMojo.outputDirectory + + + outputFileName + java.lang.String + false + true + Sets the name of the output file when compiling a set of sources to a single file. + + expression="${project.build.finalName}" + + + outputTimestamp + java.lang.String + 3.12.0 + false + true + Timestamp for reproducible output archive entries, either formatted as ISO 8601 yyyy-MM-dd'T'HH:mm:ssXXX or as an int representing seconds since the epoch (like SOURCE_DATE_EPOCH <https://reproducible-builds.org/docs/source-date-epoch/>). + + + parameters + boolean + 3.6.2 + false + true + Set to true to generate metadata for reflection on method parameters. + See also: javac -parameters <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-parameters> + + + proc + java.lang.String + 2.2 + false + true + + 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. full is the default. Starting with JDK 21, this option must be set explicitly. + See also: javac -proc <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-proc>, javac Annotation Processing <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#annotation-processing> + + + project + org.apache.maven.project.MavenProject + true + false + The current project instance. This is used for propagating generated-sources paths as compile/testCompile source roots. + + + release + java.lang.String + 3.6 + false + true + The -release argument for the Java compiler, supported since Java9 + See also: javac -release <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-release> + + + session + org.apache.maven.execution.MavenSession + true + false + The current build session instance. This is used for toolchain manager API calls. + + + showCompilationChanges + boolean + false + true + + + + showDeprecation + boolean + false + true + Sets whether to show source locations where deprecated APIs are used. + + + showWarnings + boolean + false + true + Set to false to disable warnings during compilation. + + + skip + boolean + false + true + Set this to 'true' to bypass compilation of test sources. Its use is NOT RECOMMENDED, but quite convenient on occasion. + + + skipMultiThreadWarning + boolean + 2.5 + false + true + + + + source + java.lang.String + false + true + + 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 + + Since 3.11.0 the default value has changed from 1.7 to 1.8 + + See also: javac -source <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-source> + + + staleMillis + int + false + true + Sets the granularity in milliseconds of the last modification date for testing whether a source needs recompilation. + + + target + java.lang.String + false + true + + 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 + + Since 3.11.0 the default value has changed from 1.7 to 1.8 + + See also: javac -target <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-target> + + + testCompilerArgument + java.lang.String + 2.1 + false + true + + 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. + + + + testCompilerArguments + java.util.Map + 2.1 + false + true + + 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. + + + + testExcludes + java.util.Set + false + true + A list of exclusion filters for the compiler. + + + testIncludes + java.util.Set + false + true + A list of inclusion filters for the compiler. + + + testIncrementalExcludes + java.util.Set + 3.11 + false + true + A list of exclusion filters for the incremental calculation. + + + testPath + java.util.List + false + false + + + + testRelease + java.lang.String + 3.6 + false + true + the -release argument for the test Java compiler + + + testSource + java.lang.String + 2.1 + false + true + The -source argument for the test Java compiler. + + + testTarget + java.lang.String + 2.1 + false + true + The -target argument for the test Java compiler. + + + useIncrementalCompilation + boolean + 3.1 + false + true + + to 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. + + + useModulePath + boolean + 3.11 + false + true + + 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. When false, always uses the class path. + + + + verbose + boolean + false + true + Set to true to show messages about what the compiler is doing. + See also: javac -verbose <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-verbose> + + + + + + + + ${maven.compiler.compilerId} + ${maven.compiler.compilerReuseStrategy} + ${maven.compiler.compilerVersion} + ${maven.compiler.createMissingPackageInfoClass} + ${maven.compiler.debug} + + ${maven.compiler.debuglevel} + ${maven.compiler.enablePreview} + ${encoding} + ${maven.compiler.executable} + ${maven.compiler.failOnError} + ${maven.compiler.failOnWarning} + + ${maven.compiler.forceJavacCompilerUse} + ${maven.compiler.forceLegacyJavacApi} + ${maven.compiler.fork} + + ${maven.compiler.implicit} + ${maven.compiler.maxmem} + ${maven.compiler.meminitial} + + ${maven.compiler.optimize} + + + ${maven.compiler.parameters} + ${maven.compiler.proc} + + ${maven.compiler.release} + + ${maven.compiler.showCompilationChanges} + ${maven.compiler.showDeprecation} + ${maven.compiler.showWarnings} + ${maven.test.skip} + ${maven.compiler.skipMultiThreadWarning} + ${maven.compiler.source} + ${lastModGranularityMs} + ${maven.compiler.target} + + ${maven.compiler.testRelease} + ${maven.compiler.testSource} + ${maven.compiler.testTarget} + ${maven.compiler.useIncrementalCompilation} + + ${maven.compiler.verbose} + + + + org.apache.maven.artifact.handler.manager.ArtifactHandlerManager + artifactHandlerManager + + + org.codehaus.plexus.compiler.manager.CompilerManager + compilerManager + + + org.eclipse.aether.RepositorySystem + repositorySystem + + + org.apache.maven.toolchain.ToolchainManager + toolchainManager + + + + + + + javax.inject + javax.inject + jar + 1 + + + org.slf4j + slf4j-api + jar + 1.7.36 + + + org.ow2.asm + asm + jar + 9.8 + + + org.apache.maven.shared + maven-shared-utils + jar + 3.4.2 + + + commons-io + commons-io + jar + 2.11.0 + + + org.apache.maven.shared + maven-shared-incremental + jar + 1.1 + + + org.codehaus.plexus + plexus-java + jar + 1.5.0 + + + com.thoughtworks.qdox + qdox + jar + 2.2.0 + + + org.codehaus.plexus + plexus-compiler-api + jar + 2.15.0 + + + org.codehaus.plexus + plexus-compiler-manager + jar + 2.15.0 + + + org.codehaus.plexus + plexus-compiler-javac + jar + 2.15.0 + + + org.codehaus.plexus + plexus-utils + jar + 4.0.2 + + + \ No newline at end of file diff --git a/plugins/maven/src/test/resources/org/jetbrains/maven/plugin-test/compiler-4-0-beta3.xml b/plugins/maven/src/test/resources/org/jetbrains/maven/plugin-test/compiler-4-0-beta3.xml new file mode 100644 index 000000000000..0cf9d6db5fbe --- /dev/null +++ b/plugins/maven/src/test/resources/org/jetbrains/maven/plugin-test/compiler-4-0-beta3.xml @@ -0,0 +1,1313 @@ + + + + + + Apache Maven Compiler Plugin + The Compiler Plugin is used to compile the sources of your project. + org.apache.maven.plugins + maven-compiler-plugin + 4.0.0-beta-3 + compiler + false + true + 17 + 4.0.0-rc-4 + + + compile + Compiles application sources. Each instance shall be used only once, then discarded. + See also: javac Command <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html> + false + true + false + false + true + compile + org.apache.maven.plugin.compiler.CompilerMojo + java + 2.0 + + + annotationProcessorPaths + java.util.List + 3.5 + Replaced by ordinary dependencies with <type> element set to processor, classpath-processor or modular-processor. + false + true + Classpath elements to supply as annotation processor path. If specified, the compiler will detect annotation processors only in those classpath elements. If omitted (and proc is set to only or full), the default classpath is used to detect annotation processors. The detection itself depends on the configuration of annotationProcessors. Since JDK 23 by default no annotation processing is performed as long as no processors is listed for security reasons. Therefore, you should always list the desired processors using this configuration element or annotationProcessorPaths. + 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. + See also: javac -processorpath <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-processor-path>, javac Annotation Processing <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#annotation-processing> + + + annotationProcessorPathsUseDepMgmt + boolean + 3.12.0 + This flag is ignored. Replaced by ordinary dependencies with <type> element set to processor, classpath-processor or modular-processor. + false + true + 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. + + false + + + annotationProcessors + java.lang.String[] + 2.2 + false + true + Class names of annotation processors to run. If not set, the default annotation processors discovery process applies. If set, the value will be appended to the -processor compiler option. + See also: proc + + + basedir + java.nio.file.Path + true + false + The directory to run the compiler from if fork is true. + ${project.basedir} + + + basedir2ForTest + java.nio.file.Path + true + false + The directory to run the compiler from if fork is true. + + + + compileSourceRoots + java.util.List + Replaced by the project-wide <sources> element. + false + true + The root directories containing the source files to be compiled. If null or empty, the directories will be obtained from the <Source> elements declared in the project. If non-empty, the project <Source> elements are ignored. This configuration option should be used only when there is a need to override the project configuration. + + + compilerArgs + java.util.List + 3.1 + false + true + Additional arguments to be passed verbatim to the Java compiler. This parameter can be used when the Maven compiler plugin does not provide a parameter for a Java compiler option. It may happen, for example, for new or preview Java features which are not yet handled by this compiler plugin. + If an option has a value, the option and the value shall be specified in two separated <arg> elements. For example, the -Xmaxerrs 1000 option (for setting the maximal number of errors to 1000) can be specified as below (together with other options): + <compilerArgs> <arg>-Xlint</arg> <arg>-Xmaxerrs</arg> <arg>1000</arg> <arg>J-Duser.language=en_us</arg> </compilerArgs> Note that -J options should be specified only if fork is set to true. Other options can be specified regardless the fork value. The compiler plugin does not verify whether the arguments given through this parameter are valid. For this reason, the other parameters provided by the compiler plugin should be preferred when they exist, because the plugin checks whether the corresponding options are supported. + See also: javac -J <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-J> + + + compilerArgument + java.lang.String + Use compilerArgs instead. + false + true + The single argument string to be passed to the compiler. To pass multiple arguments such as -Xmaxerrs 1000 (which are actually two arguments), compilerArgs is preferred. + Note that -J options should be specified only if fork is set to true. + + See also: javac -J <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-J> + + + compilerId + java.lang.String + false + true + Identifier of the compiler to use. This identifier shall match the identifier of a compiler known to the JDK tool chain, or the JavaCompiler#name() name of a javax.tools.JavaCompiler instance registered as a service findable by java.util.ServiceLoader. See this guide for more information. If unspecified, then the system Java compiler is used. The identifier of the system Java compiler is usually javac. + See also: fork, executable, JavaCompiler#name() + ${maven.compiler.compilerId} + + + compilerReuseStrategy + java.lang.String + 2.5 + Not supported anymore. The reuse of javax.tools.JavaFileManager instance is plugin implementation details. + false + true + Strategy to re use javacc class created. Legal values are: + * reuseCreated (default) – will reuse already created but in case of multi-threaded builds, each thread will have its own instance. + * reuseSame – the same Javacc class will be used for each compilation even for multi-threaded build. + * alwaysNew – 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. + ${maven.compiler.compilerReuseStrategy} + + + compilerVersion + java.lang.String + This parameter is no longer used by the underlying compilers. + false + true + Version of the compiler to use if fork is set to true. Examples! "1.3", "1.5". + See also: fork + ${maven.compiler.compilerVersion} + + + createMissingPackageInfoClass + boolean + 3.10 + false + true + Whether to generate package-info.class even when empty. By default, package info source files that only contain javadoc and no annotation on the package can lead to no class file being generated by the compiler. It may cause a file miss on build systems that check for file existence in order to decide what to recompile. + If true, the -Xpkginfo:always compiler option is added if the compiler supports that extra option. If the extra option is not supported, then a warning is logged and no option is added to the compiler arguments. + + See also: incrementalCompilation + ${maven.compiler.createMissingPackageInfoClass} + false + + + debug + boolean + Setting this flag to false is replaced by <debuglevel>none</debuglevel>. + false + true + Whether to include debugging information in the compiled class files. The amount of debugging information to include is specified by the debuglevel parameter. If this debug flag is true, then the -g option may be added to compiler arguments with a value determined by the debuglevel argument. If this debug flag is false, then the -g:none option will be added to the compiler arguments. + See also: debuglevel, javac -g <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-g> + ${maven.compiler.debug} + true + + + debugFileName + java.lang.String + 3.10.0 + false + true + The file where to dump the command-line when debug is activated or when the compilation failed. For example, if the value is "javac", then the Java compiler can be launched from the command-line by typing javac @target/javac.args. The debug file will contain the compiler options together with the list of source files to compile. + By default, this debug file is written only if the compilation of main code failed. The writing of the debug files can be forced by setting the verbose flag to true or by specifying the --verbose option to Maven on the command-line. + + javac.args + + + debuglevel + java.lang.String + 2.1 + false + true + Kinds of debugging information to include in the compiled class files. Legal values are lines, vars, source, all and none. Values other than all and none can be combined in a comma-separated list. + If debug level is not specified, then the -g option will not be added, which means that the default debugging information will be generated (typically lines and source but not vars). + + If debug level is all, then only the -g option is added, which means that all debugging information will be generated. If debug level is anything else, then the comma-separated list of keywords is appended to the -g command-line switch. + + See also: javac -g:[lines,vars,source] <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-g-custom> + ${maven.compiler.debuglevel} + + + enablePreview + boolean + 3.10.1 + false + true + Whether to enable preview language features of the java compiler. If true, then the --enable-preview option will be added to compiler arguments. + See also: javac --enable-preview <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-enable-preview> + ${maven.compiler.enablePreview} + false + + + encoding + java.lang.String + 2.1 + false + true + The -encoding argument for the Java compiler. + See also: javac -encoding <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-encoding> + ${encoding} + ${project.build.sourceEncoding} + + + excludes + java.util.Set + false + true + A set of exclusion filters for the compiler. + + + executable + java.lang.String + false + true + Executable of the compiler to use when fork is true. If this parameter is specified, then the jdkToolchain is ignored. + See also: jdkToolchain, fork, compilerId + ${maven.compiler.executable} + + + failOnError + boolean + 2.0.2 + false + true + Whether the build will stop if there are compilation errors. + See also: failOnWarning + ${maven.compiler.failOnError} + true + + + failOnWarning + boolean + 3.6 + false + true + Whether the build will stop if there are compilation warnings. If true, then the -Werror option will be added to compiler arguments. + See also: showWarnings, showDeprecation + ${maven.compiler.failOnWarning} + false + + + fileExtensions + java.util.List + 3.1 + false + true + File extensions to check timestamp for incremental build. Default contains only class and jar. TODO: Rename with a name making clearer that this parameter is about incremental build. + See also: incrementalCompilation + class,jar + + + forceJavacCompilerUse + java.lang.Boolean + 3.0 + Ignored because java.lang.Compiler has been deprecated and removed from the JDK. + false + true + Whether to use legacy compiler API. + ${maven.compiler.forceJavacCompilerUse} + + + forceLegacyJavacApi + java.lang.Boolean + 3.13 + Ignored because the compiler plugin now always use the javax.tools API. + false + true + Whether to use the legacy com.sun.tools.javac API instead of javax.tools API. + See also: New API <https://docs.oracle.com/en/java/javase/17/docs/api/java.compiler/javax/tools/package-summary.html>, Legacy API <https://docs.oracle.com/en/java/javase/17/docs/api/jdk.compiler/com/sun/tools/javac/package-summary.html> + ${maven.compiler.forceLegacyJavacApi} + + + fork + boolean + false + true + Allows running the compiler in a separate process. If false, the plugin uses the built-in compiler, while if true it will use an executable. + See also: executable, compilerId, meminitial, maxmem + ${maven.compiler.fork} + false + + + generatedSourcesDirectory + java.nio.file.Path + 2.2 + false + true + Specify where to place generated source files created by annotation processing. + ${project.build.directory}/generated-sources/annotations + + + implicit + java.lang.String + 3.10.2 + false + true + Whether to generate class files for implicitly referenced files. If set, the value will be appended to the -implicit: compiler option. Standard values are: + * class – automatically generates class files. + * none – suppresses class file generation. + See also: javac -implicit <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-implicit> + ${maven.compiler.implicit} + + + includes + java.util.Set + false + true + A set of inclusion filters for the compiler. + + + incrementalCompilation + java.lang.String + 4.0.0 + false + true + The algorithm to use for selecting which files to compile. Values can be dependencies, sources, classes, rebuild-on-change, rebuild-on-add, modules or none. + options: recompile all source files if the compiler options changed. Changes are detected on a best-effort basis only. + + dependencies: recompile all source files if at least one dependency (JAR file) changed since the last build. This check is based on the last modification times of JAR files. + + sources: recompile source files modified since the last build. In addition, if a source file has been deleted, then all source files are recompiled. This check is based on the modification times of source files rather than the modification times of the *.class files. + + classes: recompile source files (*.java) associated to no output file (*.class) or associated to an output file older than the source. This algorithm does not check if a source file has been removed, potentially leaving non-recompiled classes with references to classes that no longer exist. + + The sources and classes values are partially redundant, doing the same work in different ways. It is usually not necessary to specify those two values. + + modules: recompile modules and let the compiler decides which individual files to recompile. The compiler plugin does not enumerate the source files to recompile (actually, it does not scan at all the source directories). Instead, it only specifies the module to recompile using the --module option. The Java compiler will scan the source directories itself and compile only those source files that are newer than the corresponding files in the output directory. + + rebuild-on-add: modifier for recompiling all source files when the addition of a new file is detected. This flag is effective only when used together with sources or classes. When used with classes, it provides a way to detect class renaming (this is not needed with sources for detecting renaming). + + rebuild-on-change: modifier for recompiling all source files when a change is detected in at least one source file. This flag is effective only when used together with sources or classes. It does not rebuild when a new source file is added without change in other files, unless rebuild-on-add is also specified. + + none: the compiler plugin unconditionally specifies all sources to the Java compiler. This option is mutually exclusive with all other incremental compilation options. + + Limitations + In all cases, the current compiler-plugin does not detect structural changes other than file addition or removal. For example, the plugin does not detect whether a method has been removed in a class. + Default value + The default value depends on the context. If there is no annotation processor, then the default is "options,dependencies,sources". It means that a full rebuild will be done if the compiler options or the dependencies changed, or if a source file has been deleted. Otherwise, only the modified source files will be recompiled. + If an annotation processor is present (e.g., proc set to a value other than "none"), then the default value is same as above with the addition of "rebuild-on-add,rebuild-on-change". It means that a full rebuild will be done if any kind of change is detected. + + See also: staleMillis, fileExtensions, showCompilationChanges, createMissingPackageInfoClass + ${maven.compiler.incrementalCompilation} + + + incrementalExcludes + java.util.Set + 3.11 + false + true + A set of exclusion filters for the incremental calculation. Updated source files, if excluded by this filter, will not cause the project to be rebuilt. + Limitation + In the current implementation, those exclusion filters are applied for added or removed files, but not yet for removed files. + + + jdkToolchain + java.util.Map + 3.6 + false + true + Requirements for this JDK toolchain for using a different javac than the one of the JDK used by Maven. This overrules the toolchain selected by the maven-toolchain-plugin <https://maven.apache.org/plugins/maven-toolchains-plugin/>. See Guide to Toolchains <https://maven.apache.org/guides/mini/guide-using-toolchains.html> for more info. <configuration> <jdkToolchain> <version>11</version> </jdkToolchain> ... </configuration> <configuration> <jdkToolchain> <version>1.8</version> <vendor>zulu</vendor> </jdkToolchain> ... </configuration> + See also: fork, executable + + + maxmem + java.lang.String + 2.0.1 + false + true + Maximum size, in megabytes, of the memory allocation pool if fork is set to true. Examples: "128", "128M". Suffixes "k" (for kilobytes) and "G" (for gigabytes) are also accepted. If no suffix is provided, "M" is assumed. + See also: fork + ${maven.compiler.maxmem} + + + meminitial + java.lang.String + 2.0.1 + false + true + Initial size, in megabytes, of the memory allocation pool if fork is set to true. Examples: "64", "64M". Suffixes "k" (for kilobytes) and "G" (for gigabytes) are also accepted. If no suffix is provided, "M" is assumed. + See also: fork + ${maven.compiler.meminitial} + + + moduleVersion + java.lang.String + 4.0.0 + false + true + The --module-version argument for the Java compiler. This is ignored if not applicable, e.g., in non-modular projects. + See also: javac --module-version <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-module-version> + ${maven.compiler.moduleVersion} + ${project.version} + + + mojoStatusPath + java.nio.file.Path + true + false + Path to a file where to cache information about the last incremental build. This is used when "incremental" builds are enabled for detecting additions or removals of source files, or changes in plugin configuration. This file should be in the output directory and can be deleted at any time + ${project.build.directory}/maven-status/${mojo.plugin.descriptor.artifactId}/${mojo.executionId}.cache + + + multiReleaseOutput + boolean + 3.7.1 + Replaced by specifying the <targetVersion> value inside a <source> element. + false + true + When set to true, the classes will be placed in META-INF/versions/${release}. + Note: A jar is only a multi-release jar if META-INF/MANIFEST.MF contains Multi-Release: true. You need to set this by configuring the maven-jar-plugin <https://maven.apache.org/plugins/maven-jar-plugin/examples/manifest-customization.html>. This implies that you cannot test a multi-release jar using the outputDirectory. + + + + optimize + java.lang.Boolean + This property is ignored. + false + true + Whether to optimize the compiled code using the compiler's optimization methods. + ${maven.compiler.optimize} + + + outputDirectory + java.nio.file.Path + true + false + The directory for compiled classes. + See also: getOutputDirectory() + ${project.build.outputDirectory} + + + outputFileName + java.lang.String + Bundling many class files into a single file should be done by other plugins. + false + true + Sets the name of the output file when compiling a set of sources to a single file. + expression="${project.build.finalName}" + + + + outputTimestamp + java.lang.String + 3.12.0 + Not used by the compiler plugin since it does not generate archive. + false + true + Timestamp for reproducible output archive entries. It can be either formatted as ISO 8601 yyyy-MM-dd'T'HH:mm:ssXXX or as an int representing seconds since the epoch (like SOURCE_DATE_EPOCH <https://reproducible-builds.org/docs/source-date-epoch/>). + ${project.build.outputTimestamp} + + + parameters + boolean + 3.6.2 + false + true + Whether to generate metadata for reflection on method parameters. If true, the -parameters option will be added to compiler arguments. + See also: javac -parameters <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-parameters> + ${maven.compiler.parameters} + false + + + proc + java.lang.String + 2.2 + false + true + Configures if annotation processing and/or compilation are performed by the compiler. If set, the value will be appended to the -proc: compiler option. Possible values are: + * none – no annotation processing is performed, only compilation is done. + * only – only annotation processing is done, no compilation. + * full – annotation processing followed by compilation is done. The default value depends on the JDK used for the build. Prior to Java 23, the default was full, so annotation processing and compilation were executed without explicit configuration. For security reasons, starting with Java 23 no annotation processing is done if neither any -processor, -processor path or -processor module are set, or either only or full is set. So literally the default is none. It is recommended to always list the annotation processors you want to execute instead of using the proc configuration, to ensure that only desired processors are executed and not any "hidden" (and maybe malicious). + See also: annotationProcessors, Inside Java 2024-06-18 Quality Heads up <https://inside.java/2024/06/18/quality-heads-up/>, javac -proc <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-proc>, javac Annotation Processing <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#annotation-processing> + ${maven.compiler.proc} + + + projectArtifact + org.apache.maven.api.ProducedArtifact + true + false + Projects main artifact. + ${project.mainArtifact} + + + release + java.lang.String + 3.6 + false + true + The --release argument for the Java compiler when the sources do not declare this version. The suggested way to declare the target Java release is to specify it with the sources like below: <build> <sources> <source> <directory>src/main/java</directory> <targetVersion>17</targetVersion> </source> </sources> </build> If such <targetVersion> element is found, it has precedence over this release property. If a source does not declare a target Java version, then the value of this release property is used as a fallback. If omitted, the compiler will generate bytecodes for the Java version running the compiler. + See also: javac --release <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-release> + ${maven.compiler.release} + + + showCompilationChanges + boolean + false + true + Whether to provide more details about why a module is rebuilt. This is used only if incrementalCompilation is set to something else than "none". + See also: incrementalCompilation + ${maven.compiler.showCompilationChanges} + false + + + showDeprecation + boolean + false + true + Whether to show source locations where deprecated APIs are used. If true, then the -deprecation option will be added to compiler arguments. That option is itself a shorthand for -Xlint:deprecation. + See also: showWarnings, failOnWarning + ${maven.compiler.showDeprecation} + false + + + showWarnings + boolean + false + true + Whether to show compilation warnings. If false, then the -nowarn option will be added to compiler arguments. That option is itself a shorthand for -Xlint:none. + See also: showDeprecation, failOnWarning + ${maven.compiler.showWarnings} + true + + + skipMain + boolean + false + true + Set this to true to bypass compilation of main sources. Its use is not recommended, but quite convenient on occasion. + ${maven.main.skip} + + + skipMultiThreadWarning + java.lang.Boolean + 2.5 + Deprecated as a consequence of compilerReuseStrategy deprecation. + false + true + + ${maven.compiler.skipMultiThreadWarning} + + + source + java.lang.String + false + true + The --source argument for the Java compiler. + Notes: + + * 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. + * Since 4.0.0-beta-2 the default value has been removed. As of Java 9, the release parameter is preferred. + See also: javac --source <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-source> + ${maven.compiler.source} + + + staleMillis + int + false + true + The granularity in milliseconds of the last modification date for testing whether a source needs recompilation. + See also: incrementalCompilation + ${lastModGranularityMs} + 0 + + + target + java.lang.String + false + true + The --target argument for the Java compiler. + Notes: + + * 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. + * Since 4.0.0-beta-2 the default value has been removed. As of Java 9, the release parameter is preferred. + See also: javac --target <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-target> + ${maven.compiler.target} + + + useIncrementalCompilation + java.lang.Boolean + 3.1 + Replaced by incrementalCompilation. A value of true in this old property is equivalent to "dependencies,sources,rebuild-on-add" in the new property, and a value of false is equivalent to "classes". + false + true + Whether to enable/disable incremental compilation feature. + ${maven.compiler.useIncrementalCompilation} + + + verbose + boolean + false + true + Whether to show messages about what the compiler is doing. If true, then the -verbose option will be added to compiler arguments. In addition, files such as target/javac.args will be generated even on successful compilation. + See also: javac -verbose <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-verbose> + ${maven.compiler.verbose} + false + + + + + help + Display help information on maven-compiler-plugin. + Call mvn compiler:help -Ddetail=true -Dgoal=<goal-name> to display parameter details. + false + false + false + false + true + org.apache.maven.plugins.maven_compiler_plugin.HelpMojo + java + + + detail + boolean + false + true + If true, display all settable properties for each goal. + ${detail} + false + + + goal + java.lang.String + false + true + The name of the goal for which to show help. If unspecified, all goals will be displayed. + ${goal} + + + indentSize + int + false + true + The number of spaces per indentation level, should be positive. + ${indentSize} + 2 + + + lineLength + int + false + true + The maximum length of a display line, should be positive. + ${lineLength} + 80 + + + + + testCompile + Compiles application test sources. Each instance shall be used only once, then discarded. + See also: javac Command <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html> + false + true + false + false + true + test-compile + org.apache.maven.plugin.compiler.TestCompilerMojo + java + 2.0 + + + annotationProcessorPaths + java.util.List + 3.5 + Replaced by ordinary dependencies with <type> element set to processor, classpath-processor or modular-processor. + false + true + Classpath elements to supply as annotation processor path. If specified, the compiler will detect annotation processors only in those classpath elements. If omitted (and proc is set to only or full), the default classpath is used to detect annotation processors. The detection itself depends on the configuration of annotationProcessors. Since JDK 23 by default no annotation processing is performed as long as no processors is listed for security reasons. Therefore, you should always list the desired processors using this configuration element or annotationProcessorPaths. + 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. + See also: javac -processorpath <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-processor-path>, javac Annotation Processing <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#annotation-processing> + + + annotationProcessorPathsUseDepMgmt + boolean + 3.12.0 + This flag is ignored. Replaced by ordinary dependencies with <type> element set to processor, classpath-processor or modular-processor. + false + true + 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. + + false + + + annotationProcessors + java.lang.String[] + 2.2 + false + true + Class names of annotation processors to run. If not set, the default annotation processors discovery process applies. If set, the value will be appended to the -processor compiler option. + See also: proc + + + basedir + java.nio.file.Path + true + false + The directory to run the compiler from if fork is true. + ${project.basedir} + + + compileSourceRoots + java.util.List + Replaced by the project-wide <sources> element. + false + true + The root directories containing the source files to be compiled. If null or empty, the directories will be obtained from the <Source> elements declared in the project. If non-empty, the project <Source> elements are ignored. This configuration option should be used only when there is a need to override the project configuration. + + + compilerArgs + java.util.List + 3.1 + false + true + Additional arguments to be passed verbatim to the Java compiler. This parameter can be used when the Maven compiler plugin does not provide a parameter for a Java compiler option. It may happen, for example, for new or preview Java features which are not yet handled by this compiler plugin. + If an option has a value, the option and the value shall be specified in two separated <arg> elements. For example, the -Xmaxerrs 1000 option (for setting the maximal number of errors to 1000) can be specified as below (together with other options): + <compilerArgs> <arg>-Xlint</arg> <arg>-Xmaxerrs</arg> <arg>1000</arg> <arg>J-Duser.language=en_us</arg> </compilerArgs> Note that -J options should be specified only if fork is set to true. Other options can be specified regardless the fork value. The compiler plugin does not verify whether the arguments given through this parameter are valid. For this reason, the other parameters provided by the compiler plugin should be preferred when they exist, because the plugin checks whether the corresponding options are supported. + See also: javac -J <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-J> + + + compilerArgument + java.lang.String + Use compilerArgs instead. + false + true + The single argument string to be passed to the compiler. To pass multiple arguments such as -Xmaxerrs 1000 (which are actually two arguments), compilerArgs is preferred. + Note that -J options should be specified only if fork is set to true. + + See also: javac -J <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-J> + + + compilerId + java.lang.String + false + true + Identifier of the compiler to use. This identifier shall match the identifier of a compiler known to the JDK tool chain, or the JavaCompiler#name() name of a javax.tools.JavaCompiler instance registered as a service findable by java.util.ServiceLoader. See this guide for more information. If unspecified, then the system Java compiler is used. The identifier of the system Java compiler is usually javac. + See also: fork, executable, JavaCompiler#name() + ${maven.compiler.compilerId} + + + compilerReuseStrategy + java.lang.String + 2.5 + Not supported anymore. The reuse of javax.tools.JavaFileManager instance is plugin implementation details. + false + true + Strategy to re use javacc class created. Legal values are: + * reuseCreated (default) – will reuse already created but in case of multi-threaded builds, each thread will have its own instance. + * reuseSame – the same Javacc class will be used for each compilation even for multi-threaded build. + * alwaysNew – 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. + ${maven.compiler.compilerReuseStrategy} + + + compilerVersion + java.lang.String + This parameter is no longer used by the underlying compilers. + false + true + Version of the compiler to use if fork is set to true. Examples! "1.3", "1.5". + See also: fork + ${maven.compiler.compilerVersion} + + + createMissingPackageInfoClass + boolean + 3.10 + false + true + Whether to generate package-info.class even when empty. By default, package info source files that only contain javadoc and no annotation on the package can lead to no class file being generated by the compiler. It may cause a file miss on build systems that check for file existence in order to decide what to recompile. + If true, the -Xpkginfo:always compiler option is added if the compiler supports that extra option. If the extra option is not supported, then a warning is logged and no option is added to the compiler arguments. + + See also: incrementalCompilation + ${maven.compiler.createMissingPackageInfoClass} + false + + + debug + boolean + Setting this flag to false is replaced by <debuglevel>none</debuglevel>. + false + true + Whether to include debugging information in the compiled class files. The amount of debugging information to include is specified by the debuglevel parameter. If this debug flag is true, then the -g option may be added to compiler arguments with a value determined by the debuglevel argument. If this debug flag is false, then the -g:none option will be added to the compiler arguments. + See also: debuglevel, javac -g <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-g> + ${maven.compiler.debug} + true + + + debugFileName + java.lang.String + 3.10.0 + false + true + The file where to dump the command-line when debug is activated or when the compilation failed. For example, if the value is "javac-test", then the Java compiler can be launched from the command-line by typing javac @target/javac-test.args. The debug file will contain the compiler options together with the list of source files to compile. + By default, this debug file is written only if the compilation of test code failed. The writing of the debug files can be forced by setting the verbose flag to true or by specifying the --verbose option to Maven on the command-line. + + See also: CompilerMojo.debugFileName + javac-test.args + + + debuglevel + java.lang.String + 2.1 + false + true + Kinds of debugging information to include in the compiled class files. Legal values are lines, vars, source, all and none. Values other than all and none can be combined in a comma-separated list. + If debug level is not specified, then the -g option will not be added, which means that the default debugging information will be generated (typically lines and source but not vars). + + If debug level is all, then only the -g option is added, which means that all debugging information will be generated. If debug level is anything else, then the comma-separated list of keywords is appended to the -g command-line switch. + + See also: javac -g:[lines,vars,source] <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-g-custom> + ${maven.compiler.debuglevel} + + + enablePreview + boolean + 3.10.1 + false + true + Whether to enable preview language features of the java compiler. If true, then the --enable-preview option will be added to compiler arguments. + See also: javac --enable-preview <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-enable-preview> + ${maven.compiler.enablePreview} + false + + + encoding + java.lang.String + 2.1 + false + true + The -encoding argument for the Java compiler. + See also: javac -encoding <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-encoding> + ${encoding} + ${project.build.sourceEncoding} + + + executable + java.lang.String + false + true + Executable of the compiler to use when fork is true. If this parameter is specified, then the jdkToolchain is ignored. + See also: jdkToolchain, fork, compilerId + ${maven.compiler.executable} + + + failOnError + boolean + 2.0.2 + false + true + Whether the build will stop if there are compilation errors. + See also: failOnWarning + ${maven.compiler.failOnError} + true + + + failOnWarning + boolean + 3.6 + false + true + Whether the build will stop if there are compilation warnings. If true, then the -Werror option will be added to compiler arguments. + See also: showWarnings, showDeprecation + ${maven.compiler.failOnWarning} + false + + + fileExtensions + java.util.List + 3.1 + false + true + File extensions to check timestamp for incremental build. Default contains only class and jar. TODO: Rename with a name making clearer that this parameter is about incremental build. + See also: incrementalCompilation + class,jar + + + forceJavacCompilerUse + java.lang.Boolean + 3.0 + Ignored because java.lang.Compiler has been deprecated and removed from the JDK. + false + true + Whether to use legacy compiler API. + ${maven.compiler.forceJavacCompilerUse} + + + forceLegacyJavacApi + java.lang.Boolean + 3.13 + Ignored because the compiler plugin now always use the javax.tools API. + false + true + Whether to use the legacy com.sun.tools.javac API instead of javax.tools API. + See also: New API <https://docs.oracle.com/en/java/javase/17/docs/api/java.compiler/javax/tools/package-summary.html>, Legacy API <https://docs.oracle.com/en/java/javase/17/docs/api/jdk.compiler/com/sun/tools/javac/package-summary.html> + ${maven.compiler.forceLegacyJavacApi} + + + fork + boolean + false + true + Allows running the compiler in a separate process. If false, the plugin uses the built-in compiler, while if true it will use an executable. + See also: executable, compilerId, meminitial, maxmem + ${maven.compiler.fork} + false + + + generatedTestSourcesDirectory + java.nio.file.Path + 2.2 + false + true + Specify where to place generated source files created by annotation processing. + See also: CompilerMojo.generatedSourcesDirectory + ${project.build.directory}/generated-test-sources/test-annotations + + + implicit + java.lang.String + 3.10.2 + false + true + Whether to generate class files for implicitly referenced files. If set, the value will be appended to the -implicit: compiler option. Standard values are: + * class – automatically generates class files. + * none – suppresses class file generation. + See also: javac -implicit <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-implicit> + ${maven.compiler.implicit} + + + incrementalCompilation + java.lang.String + 4.0.0 + false + true + The algorithm to use for selecting which files to compile. Values can be dependencies, sources, classes, rebuild-on-change, rebuild-on-add, modules or none. + options: recompile all source files if the compiler options changed. Changes are detected on a best-effort basis only. + + dependencies: recompile all source files if at least one dependency (JAR file) changed since the last build. This check is based on the last modification times of JAR files. + + sources: recompile source files modified since the last build. In addition, if a source file has been deleted, then all source files are recompiled. This check is based on the modification times of source files rather than the modification times of the *.class files. + + classes: recompile source files (*.java) associated to no output file (*.class) or associated to an output file older than the source. This algorithm does not check if a source file has been removed, potentially leaving non-recompiled classes with references to classes that no longer exist. + + The sources and classes values are partially redundant, doing the same work in different ways. It is usually not necessary to specify those two values. + + modules: recompile modules and let the compiler decides which individual files to recompile. The compiler plugin does not enumerate the source files to recompile (actually, it does not scan at all the source directories). Instead, it only specifies the module to recompile using the --module option. The Java compiler will scan the source directories itself and compile only those source files that are newer than the corresponding files in the output directory. + + rebuild-on-add: modifier for recompiling all source files when the addition of a new file is detected. This flag is effective only when used together with sources or classes. When used with classes, it provides a way to detect class renaming (this is not needed with sources for detecting renaming). + + rebuild-on-change: modifier for recompiling all source files when a change is detected in at least one source file. This flag is effective only when used together with sources or classes. It does not rebuild when a new source file is added without change in other files, unless rebuild-on-add is also specified. + + none: the compiler plugin unconditionally specifies all sources to the Java compiler. This option is mutually exclusive with all other incremental compilation options. + + Limitations + In all cases, the current compiler-plugin does not detect structural changes other than file addition or removal. For example, the plugin does not detect whether a method has been removed in a class. + Default value + The default value depends on the context. If there is no annotation processor, then the default is "options,dependencies,sources". It means that a full rebuild will be done if the compiler options or the dependencies changed, or if a source file has been deleted. Otherwise, only the modified source files will be recompiled. + If an annotation processor is present (e.g., proc set to a value other than "none"), then the default value is same as above with the addition of "rebuild-on-add,rebuild-on-change". It means that a full rebuild will be done if any kind of change is detected. + + See also: staleMillis, fileExtensions, showCompilationChanges, createMissingPackageInfoClass + ${maven.compiler.incrementalCompilation} + + + jdkToolchain + java.util.Map + 3.6 + false + true + Requirements for this JDK toolchain for using a different javac than the one of the JDK used by Maven. This overrules the toolchain selected by the maven-toolchain-plugin <https://maven.apache.org/plugins/maven-toolchains-plugin/>. See Guide to Toolchains <https://maven.apache.org/guides/mini/guide-using-toolchains.html> for more info. <configuration> <jdkToolchain> <version>11</version> </jdkToolchain> ... </configuration> <configuration> <jdkToolchain> <version>1.8</version> <vendor>zulu</vendor> </jdkToolchain> ... </configuration> + See also: fork, executable + + + mainOutputDirectory + java.nio.file.Path + true + false + The output directory of the main classes. This directory will be added to the class-path or module-path. Its value should be the same as CompilerMojo.outputDirectory. + See also: CompilerMojo.outputDirectory + ${project.build.outputDirectory} + + + maxmem + java.lang.String + 2.0.1 + false + true + Maximum size, in megabytes, of the memory allocation pool if fork is set to true. Examples: "128", "128M". Suffixes "k" (for kilobytes) and "G" (for gigabytes) are also accepted. If no suffix is provided, "M" is assumed. + See also: fork + ${maven.compiler.maxmem} + + + meminitial + java.lang.String + 2.0.1 + false + true + Initial size, in megabytes, of the memory allocation pool if fork is set to true. Examples: "64", "64M". Suffixes "k" (for kilobytes) and "G" (for gigabytes) are also accepted. If no suffix is provided, "M" is assumed. + See also: fork + ${maven.compiler.meminitial} + + + moduleVersion + java.lang.String + 4.0.0 + false + true + The --module-version argument for the Java compiler. This is ignored if not applicable, e.g., in non-modular projects. + See also: javac --module-version <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-module-version> + ${maven.compiler.moduleVersion} + ${project.version} + + + mojoStatusPath + java.nio.file.Path + true + false + Path to a file where to cache information about the last incremental build. This is used when "incremental" builds are enabled for detecting additions or removals of source files, or changes in plugin configuration. This file should be in the output directory and can be deleted at any time + ${project.build.directory}/maven-status/${mojo.plugin.descriptor.artifactId}/${mojo.executionId}.cache + + + optimize + java.lang.Boolean + This property is ignored. + false + true + Whether to optimize the compiled code using the compiler's optimization methods. + ${maven.compiler.optimize} + + + outputDirectory + java.nio.file.Path + true + true + The directory where compiled test classes go. This parameter should only be modified in special cases. See the CompilerMojo.outputDirectory for more information. + See also: CompilerMojo.outputDirectory, getOutputDirectory() + ${project.build.testOutputDirectory} + + + outputFileName + java.lang.String + Bundling many class files into a single file should be done by other plugins. + false + true + Sets the name of the output file when compiling a set of sources to a single file. + expression="${project.build.finalName}" + + + + outputTimestamp + java.lang.String + 3.12.0 + Not used by the compiler plugin since it does not generate archive. + false + true + Timestamp for reproducible output archive entries. It can be either formatted as ISO 8601 yyyy-MM-dd'T'HH:mm:ssXXX or as an int representing seconds since the epoch (like SOURCE_DATE_EPOCH <https://reproducible-builds.org/docs/source-date-epoch/>). + ${project.build.outputTimestamp} + + + parameters + boolean + 3.6.2 + false + true + Whether to generate metadata for reflection on method parameters. If true, the -parameters option will be added to compiler arguments. + See also: javac -parameters <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-parameters> + ${maven.compiler.parameters} + false + + + proc + java.lang.String + 2.2 + false + true + Configures if annotation processing and/or compilation are performed by the compiler. If set, the value will be appended to the -proc: compiler option. Possible values are: + * none – no annotation processing is performed, only compilation is done. + * only – only annotation processing is done, no compilation. + * full – annotation processing followed by compilation is done. The default value depends on the JDK used for the build. Prior to Java 23, the default was full, so annotation processing and compilation were executed without explicit configuration. For security reasons, starting with Java 23 no annotation processing is done if neither any -processor, -processor path or -processor module are set, or either only or full is set. So literally the default is none. It is recommended to always list the annotation processors you want to execute instead of using the proc configuration, to ensure that only desired processors are executed and not any "hidden" (and maybe malicious). + See also: annotationProcessors, Inside Java 2024-06-18 Quality Heads up <https://inside.java/2024/06/18/quality-heads-up/>, javac -proc <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-proc>, javac Annotation Processing <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#annotation-processing> + ${maven.compiler.proc} + + + release + java.lang.String + 3.6 + false + true + The --release argument for the Java compiler when the sources do not declare this version. The suggested way to declare the target Java release is to specify it with the sources like below: <build> <sources> <source> <directory>src/main/java</directory> <targetVersion>17</targetVersion> </source> </sources> </build> If such <targetVersion> element is found, it has precedence over this release property. If a source does not declare a target Java version, then the value of this release property is used as a fallback. If omitted, the compiler will generate bytecodes for the Java version running the compiler. + See also: javac --release <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-release> + ${maven.compiler.release} + + + showCompilationChanges + boolean + false + true + Whether to provide more details about why a module is rebuilt. This is used only if incrementalCompilation is set to something else than "none". + See also: incrementalCompilation + ${maven.compiler.showCompilationChanges} + false + + + showDeprecation + boolean + false + true + Whether to show source locations where deprecated APIs are used. If true, then the -deprecation option will be added to compiler arguments. That option is itself a shorthand for -Xlint:deprecation. + See also: showWarnings, failOnWarning + ${maven.compiler.showDeprecation} + false + + + showWarnings + boolean + false + true + Whether to show compilation warnings. If false, then the -nowarn option will be added to compiler arguments. That option is itself a shorthand for -Xlint:none. + See also: showDeprecation, failOnWarning + ${maven.compiler.showWarnings} + true + + + skip + boolean + false + true + Whether to bypass compilation of test sources. Its use is not recommended, but quite convenient on occasion. + See also: CompilerMojo.skipMain + ${maven.test.skip} + + + skipMultiThreadWarning + java.lang.Boolean + 2.5 + Deprecated as a consequence of compilerReuseStrategy deprecation. + false + true + + ${maven.compiler.skipMultiThreadWarning} + + + source + java.lang.String + false + true + The --source argument for the Java compiler. + Notes: + + * 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. + * Since 4.0.0-beta-2 the default value has been removed. As of Java 9, the release parameter is preferred. + See also: javac --source <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-source> + ${maven.compiler.source} + + + staleMillis + int + false + true + The granularity in milliseconds of the last modification date for testing whether a source needs recompilation. + See also: incrementalCompilation + ${lastModGranularityMs} + 0 + + + target + java.lang.String + false + true + The --target argument for the Java compiler. + Notes: + + * 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. + * Since 4.0.0-beta-2 the default value has been removed. As of Java 9, the release parameter is preferred. + See also: javac --target <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-target> + ${maven.compiler.target} + + + testCompilerArgs + java.util.List + 4.0.0 + false + true + The arguments to be passed to the test compiler. If this parameter is specified, it replaces compilerArgs. Otherwise, the compilerArgs parameter is used. + See also: CompilerMojo#compilerArgs + + + testCompilerArgument + java.lang.String + 2.1 + Use testCompilerArgs instead. + false + true + The single argument string to be passed to the test compiler. If this parameter is specified, it replaces compilerArgument. Otherwise, the compilerArgument parameter is used. + See also: CompilerMojo#compilerArgument + + + testCompilerArguments + java.util.Map + 2.1 + Replaced by testCompilerArgs for consistency with the main phase. + false + true + The arguments to be passed to test compiler. + + + testExcludes + java.util.Set + false + true + A set of exclusion filters for the compiler. + See also: CompilerMojo.excludes + + + testIncludes + java.util.Set + false + true + A set of inclusion filters for the compiler. + See also: CompilerMojo.includes + + + testIncrementalExcludes + java.util.Set + 3.11 + false + true + A set of exclusion filters for the incremental calculation. Updated files, if excluded by this filter, will not cause the project to be rebuilt. + See also: CompilerMojo.incrementalExcludes + + + testRelease + java.lang.String + 3.6 + false + true + the --release argument for the test Java compiler + See also: CompilerMojo#release + ${maven.compiler.testRelease} + + + testSource + java.lang.String + 2.1 + false + true + The --source argument for the test Java compiler. + See also: CompilerMojo#source + ${maven.compiler.testSource} + + + testTarget + java.lang.String + 2.1 + false + true + The --target argument for the test Java compiler. + See also: CompilerMojo#target + ${maven.compiler.testTarget} + + + useIncrementalCompilation + java.lang.Boolean + 3.1 + Replaced by incrementalCompilation. A value of true in this old property is equivalent to "dependencies,sources,rebuild-on-add" in the new property, and a value of false is equivalent to "classes". + false + true + Whether to enable/disable incremental compilation feature. + ${maven.compiler.useIncrementalCompilation} + + + useModulePath + boolean + 3.11 + Use "claspath-jar" dependency type instead, and avoid module-info.java in tests. + false + true + Whether to place the main classes on the module path when module-info is present. When false, always places the main classes on the class path. Dependencies are also placed on the class-path, unless their type is module-jar. + true + + + verbose + boolean + false + true + Whether to show messages about what the compiler is doing. If true, then the -verbose option will be added to compiler arguments. In addition, files such as target/javac.args will be generated even on successful compilation. + See also: javac -verbose <https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-verbose> + ${maven.compiler.verbose} + false + + + + + \ No newline at end of file