[MNG-8656] Maven cannot be embedded in applications that have upgraded Guice to 7.0+
- Dominant language
- Java
- Stars
- 5.3k
- Forks
- 3.1k
- Avg merge
- 21h 11m
- Merged PRs (30d)
- 312
Description
**[Basil Crow](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=basil)** opened **[MNG-8656](https://issues.apache.org/jira/browse/MNG-8656?redirect=false)** and commented
With Java 17, install Jenkins 2.503, create a Maven installation for Maven 3.9.9, and create a Maven project building e.g. https://github.com/basil/simple-maven-project-with-tests. The job should succeed.
Now run the same job against https://github.com/jenkinsci/jenkins/pull/8889 which upgrades Guice from 6.0 (which supports both `javax.inject` and `jakarta.inject` imports) to 7.0 (which only supports jakarta.inject imports). The job fails with:
```
java.lang.IllegalArgumentException: org.eclipse.sisu.Parameters is not a binding annotation. Please annotate it with @BindingAnnotation.
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:218)
at com.google.inject.Key.ensureIsBindingAnnotation(Key.java:382)
at com.google.inject.Key.strategyFor(Key.java:370)
at com.google.inject.Key.get(Key.java:229)
at org.eclipse.sisu.wire.ParameterKeys.(ParameterKeys.java:28)
Caused: java.lang.ExceptionInInitializerError
at org.eclipse.sisu.wire.DependencyAnalyzer.(DependencyAnalyzer.java:93)
at org.eclipse.sisu.wire.ElementAnalyzer.(ElementAnalyzer.java:104)
at org.eclipse.sisu.wire.WireModule.configure(WireModule.java:74)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:426)
at com.google.inject.spi.Elements.getElements(Elements.java:113)
at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:160)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107)
at com.google.inject.Guice.createInjector(Guice.java:87)
at com.google.inject.Guice.createInjector(Guice.java:69)
at com.google.inject.Guice.createInjector(Guice.java:59)
at org.codehaus.plexus.DefaultPlexusContainer.addPlexusInjector(DefaultPlexusContainer.java:481)
at org.codehaus.plexus.DefaultPlexusContainer.(DefaultPlexusContainer.java:206)
at org.codehaus.plexus.DefaultPlexusContainer.(DefaultPlexusContainer.java:168)
at hudson.maven.MavenEmbedderUtils.buildPlexusContainer(MavenEmbedderUtils.java:166)
at hudson.maven.MavenEmbedderUtils.buildPlexusContainer(MavenEmbedderUtils.java:159)
at hudson.maven.MavenEmbedder.(MavenEmbedder.java:110)
at hudson.maven.MavenEmbedder.(MavenEmbedder.java:137)
at hudson.maven.MavenUtil.createEmbedder(MavenUtil.java:211)
at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:1324)
at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:1124)
at hudson.FilePath.act(FilePath.java:1236)
at hudson.FilePath.act(FilePath.java:1219)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.parsePoms(MavenModuleSetBuild.java:985)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:689)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:526)
at hudson.model.Run.execute(Run.java:1895)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
at hudson.model.ResourceController.execute(ResourceController.java:101)
at hudson.model.Executor.run(Executor.java:442)
```
This is blocking the Jenkins project from upgrading Guice from 6.0 to 7.0.
This problem was previously raised in MNG-8027, where it was suggested that Maven moving away from Guice may be a long-term direction that resolves this problem. As long the above symptom persists, the problem remains unresolved. Closing the ticket based on a future plan that has not yet been implemented does not eliminate the current problem. This ticket tracks the current problem—namely, that Maven cannot currently be embedded into an application running the latest version of Guice. It ought to be possible to embed Maven into any application with up-to-date dependencies; otherwise, Maven would be holding that application back. When Maven can be embedded into an application running up-to-date dependencies, this ticket can be closed—regardless of how that goal is achieved (e.g., Maven upgrading to Guice 7 or later, Maven upgrading to Guice 6.x and migrating from `javax.inject` to `jakarta.inject`, Maven moving away from Guice as described in MNG-8027, or another solution entirely).
---
**Affects:** 3.9.9
**Issue Links:**
- [MNG-8027](https://issues.apache.org/jira/browse/MNG-8027) Maven cannot be embedded in applications that have upgraded Guice to 7.0+
Contributor guide
Research direction
Reproduce the Java 17 failure with Maven 3.9.9 and the Jenkins Maven project described in the issue. Start with MavenEmbedderUtils and MavenEmbedder, then follow the stack trace through org.eclipse.sisu.wire.ParameterKeys and DependencyAnalyzer; done means Maven can be embedded by an application using Guice 7.0 or later.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100