So the problem is coming from the fact that the MojoExtension is creating a
config for the plugin with the following snippet:

<compileSourceRoots>
  
<compileSourceRoot>${project.basedir}/src/main/java</compileSourceRoot>${project.basedir}/src/test/java
</compileSourceRoots>

merging the value from the xml, and from the @MojoParameter annotation.
At injection, with rc-4, the xml was converted to an XmlPlexusConfiguration
and injected correctly.
In rc-5, the injection of this config snippet does not work anymore.
This is a regression caused by
https://github.com/apache/maven/commit/d3bd71bbdf2e88f1674b4e977a7c8c5547df9e1b,
and in particular, the EnhancedCompositeBeanHelper#setFieldValue which
wrongly caches field accessibility.

However, the input still looks very wrong, but the MojoExtension does not
provide a way to inject complex values at the moment.


Le sam. 8 nov. 2025 à 11:14, Martin Desruisseaux
<[email protected]> a écrit :

> Hello Guillaume
>
> I tested RC-5 with the compiler plugin. In the JUnit tests, mocks are
> created like below (example from CompilerMojoTestCase.java line 128):
>
>     @Test
>     @Basedir("${basedir}/target/test-classes/unit/compiler-basic-test")
>     public void testCompilerBasic(
>              @InjectMojo(goal = "compile", pom = "plugin-config.xml")
> CompilerMojo compileMojo,
>              @InjectMojo(goal = "testCompile", pom = "plugin-config.xml")
>                      @MojoParameter(name = "compileSourceRoots", value =
> "${project.basedir}/src/test/java")
>                      TestCompilerMojo testCompileMojo) {
>
> With Maven 4.0.0-rc-4, the AbstractCompilerMojo.compileSourceRoots field
> is correctly initialized to the "${project.basedir}/src/test/java" value
> during compilation of tests. But with Maven 4.0.0-rc-5, the field is
> non-null only for the main goal and is null for the test goal, causing
> the JUnit tests to fail. Is it a regression, or does the parameter needs
> to be defined otherwise?
>
> The issue can be reproduced as below:
>
>   * Checkout the master branch of Maven Compiler Plugin
>     (c3fc26a31d1a7dc3d98cb3d3769de32306467741).
>   * In the pom.xml at line 85, change 4.0.0-rc-4 to 4.0.0-rc-5. Add the
>     staging repository.
>   * In AbstractCompilerMojo, put break points on lines 1059 and 1062
>     (the two branches of a if - else).
>   * Run CompilerMojoTestCase in a debugger.
>
> The debugger should never hit the break point at line 1059 (the case
> when compileSourceRoots is absent). This is verified with RC-4. But with
> RC-5, it seems to be the case for every tests.
>
>      Martin
>
>

-- 
------------------------
Guillaume Nodet

Reply via email to