artemmukhin opened a new issue, #14174:
URL: https://github.com/apache/maven/issues/14174

   ### Affected version
   
   `maven-4.0.x` at `468bda953a` (snapshot `4.0.0-20261127.234307-684`)
   
   ### Bug description
   
   The released maven-compiler-plugin 4.0.0-beta-5 and 4.0.0-beta-4 fail on the 
current `maven-4.0.x` branch before they compile:
   
   ```text
   Unable to lookup Mojo: Error while initializing binding 
BindingToConstructor[@Named("org.apache.maven.plugins:maven-compiler-plugin:4.0.0-beta-5:compile")
 CompilerMojoFactory ...]:
   Ambiguous bindings for key ArtifactManager:
    - BindingToConstructor[ArtifactManager, static ... 
org.apache.maven.plugin.compiler.Providers.artifactManager(org.apache.maven.api.Session)]
 (priority=0)
    - BindingToSupplier[ArtifactManager, 
org.apache.maven.impl.AbstractSession$$Lambda/...] (priority=0)
   Use a qualifier or a distinct @Priority to select a single binding.
   ```
   
   The default bindings are not affected: with no plugin version, Maven 4.0.x 
uses maven-compiler-plugin 3.16.0, and the build passes. The CI of 
maven-compiler-plugin tests Maven 4 only with 4.0.0-rc-7 (the default 
`maven4-version` of `apache/maven-gh-actions-shared` `maven-verify.yml@v5`), so 
it does not see this.
   
   #### Reproducer
   
   `pom.xml`, with an empty `.mvn` directory and one class in `src/main/java`:
   
   ```xml
   <project xmlns="http://maven.apache.org/POM/4.0.0";>
     <modelVersion>4.0.0</modelVersion>
     <groupId>t</groupId><artifactId>compat</artifactId><version>1</version>
     
<properties><maven.compiler.release>17</maven.compiler.release></properties>
     <build><plugins><plugin>
       
<groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>4.0.0-beta-5</version>
     </plugin></plugins></build>
   </project>
   ```
   
   `mvn -Dmaven.repo.local=<empty folder> compile`:
   
   | Maven | Result |
   |---|---|
   | 4.0.0-rc-7 | BUILD SUCCESS |
   | 4.0.0-SNAPSHOT, `maven-4.0.x` `468bda953a` (also `fae5ab1655`) | the error 
above |
   | 4.2.0-SNAPSHOT, master | BUILD SUCCESS |
   | `fae5ab1655` with `cc6ce0bfe8` (#13942) cherry-picked | BUILD SUCCESS |
   
   maven-clean-plugin 4.0.0-beta-3, maven-resources-plugin 4.0.0-beta-2, 
maven-jar-plugin 4.0.0-beta-2 and maven-install-plugin 4.0.0-beta-3 pass on 
rc-7, on `maven-4.0.x`, on master and with the cherry-pick.
   
   #### Possible Cause
   
   1. `DefaultMavenPluginManager.loadV4Mojo` binds every session service with 
`bindSupplier`. rc-7 did this too.
   2. #13545, the 4.0.x backport of the fix for #13469 (`3e1cb9177d`), makes 
`InjectorImpl` fail when two unqualified bindings have the same priority.
   3. maven-compiler-plugin 4.x declares its own `@Provides ArtifactManager` in 
`Providers`. So two bindings at priority 0 meet.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to