-
Notifications
You must be signed in to change notification settings - Fork 0
Changes in compiler parameters
In its current version, the new plugin does not remove any parameters that exist in the compiler plugin of Maven 3. However, the behaviour of some parameters has been modified and some parameters are deprecated. This page lists the changes.
The way to handle compiler options has been modified.
Previously, the Maven plugin validated some options before to pass them to the compiler.
For example, if the <debuglevel>
value contains anything else than lines
, vars
or source
, the plugin raised an error.
The intend was to provide more informative message.
But in the javax.tools.JavaCompiler
interface, there is an API telling us whether an option is supported.
Therefor, the new plugin version first asks to the compiler whether the option is supported,
and only if the compiler said "no", the validation is performed for producing the error message.
Consequently, if the compiler claims to support the -g:foo
option,
then the plugin will no longer block the use of the foo
value in <debuglevel>
even if the plugin does not know that value.
The set of plugin parameters is the same as before: no addition and no removal, but there is some deprecations. The following parameters are deprecated but are still working:
-
<compilerArgument>
(a single String): already replaced by<compilerArgs>
(a list of Strings) since Maven 3.1. -
<annotationProcessorPaths>
: replaced by ordinary dependencies with<type>proc</type>
, a new artifact type introduced in Maven 4-alpha13.
The following parameters are marked as deprecated for removal. They all became no-op in the new plugin:
-
<forceJavacCompilerUse>
: the documentation is not really explicit, but it seems to be about forcing the use ofjava.lang.Compiler
instead ofjavax.tools.JavaCompiler
. The former class was deprecated since Java 9 and no longer exists in Java 21. -
<outputFileName>
: merging many archive files into a single JAR file can be considered as the task of separated plugins, for example the JAR plugin. Furthermore, this parameter does not work well in the context of Module Source Hierarchy, because the output is not a single JAR. -
<compilerReuseStrategy>
: the way that thejavax.tools.JavaCompiler
API is designed, this parameter does not seem relevant to instances of that interface. The parameter may be partially relevant to some objects used byJavaCompiler
, but not fully (e.g. thereuseSame
parameter value stay inapplicable). -
<skipMultiThreadWarning>
: deprecated as a consequence of<compilerReuseStrategy>
deprecation.
The following parameters had their default value modified:
-
<source>
and<target>
: removed the default value and added a Javadoc saying "As of Java 9, the --release option is preferred." Its default value (if any) has not yet been chosen. - The magic done by compiler and test MOJOs for trying to setup automatically some values of
--patch-module
and--add-reads
options has been removed. This magic was done for multi-versions and for tests compilation.