[Commented] (MRESOLVER-96) Dependency Injection fails after upgrading to Maven 3.6.2

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Commented] (MRESOLVER-96) Dependency Injection fails after upgrading to Maven 3.6.2

Sylwester Lachiewicz (Jira)

    [ https://issues.apache.org/jira/browse/MRESOLVER-96?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17015761#comment-17015761 ]

Marek Neumann commented on MRESOLVER-96:
----------------------------------------

Thanks for having a glance and for the workaround. We found another easier way to include the resolver without having the need for the Guice dependency. Will there be a fix in the next release for the regression with Maven >=3.6.2?

> Dependency Injection fails after upgrading to Maven 3.6.2
> ---------------------------------------------------------
>
>                 Key: MRESOLVER-96
>                 URL: https://issues.apache.org/jira/browse/MRESOLVER-96
>             Project: Maven Resolver
>          Issue Type: Bug
>          Components: resolver
>    Affects Versions: 1.4.1
>            Reporter: Marek Neumann
>            Priority: Minor
>
> When using Maven Resolver 1.4.1 in combination with Maven 3.6.2 (also 3.6.3) we face the following errors when we bootstrap our application:
> {code:java}
> Exception in thread "main" com.google.inject.CreationException: Unable to create injector, see the following errors:1) No implementation for org.apache.maven.model.composition.DependencyManagementImporter was bound.
>   while locating org.apache.maven.model.composition.DependencyManagementImporter
>     for field at org.apache.maven.model.building.DefaultModelBuilder.dependencyManagementImporter(DefaultModelBuilder.java:207)
>   at org.apache.maven.repository.internal.MavenResolverModule.configure(MavenResolverModule.java:58) (via modules: build.development.boot.Bootstrap$ResolverModule -> org.apache.maven.repository.internal.MavenResolverModule)2) No implementation for org.apache.maven.model.management.DependencyManagementInjector was bound.
>   while locating org.apache.maven.model.management.DependencyManagementInjector
>     for field at org.apache.maven.model.building.DefaultModelBuilder.dependencyManagementInjector(DefaultModelBuilder.java:213)
>   at org.apache.maven.repository.internal.MavenResolverModule.configure(MavenResolverModule.java:58) (via modules: build.development.boot.Bootstrap$ResolverModule -> org.apache.maven.repository.internal.MavenResolverModule)
> ...
> 17 errors
> at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:470)
> at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:155)
> at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107)
> at com.google.inject.Guice.createInjector(Guice.java:99)
> at com.google.inject.Guice.createInjector(Guice.java:73)
> at com.google.inject.Guice.createInjector(Guice.java:62){code}
> The relevant code part is:
> {code:java}
> Guice.createInjector(new ResolverModule()).getInstance(RepositorySystem.class);
> static class ResolverModule extends AbstractModule {
>     @Override
>     protected void configure() {
>         install(new MavenResolverModule());
>         bind(RepositoryConnectorFactory.class).annotatedWith(Names.named("basic")).to(BasicRepositoryConnectorFactory.class);
>         bind(TransporterFactory.class).annotatedWith(Names.named("file")).to(FileTransporterFactory.class);
>         bind(TransporterFactory.class).annotatedWith(Names.named("http")).to(HttpTransporterFactory.class);
>     }
>     @Provides
>     @Singleton
>     Set<RepositoryConnectorFactory> provideRepositoryConnectorFactories(@Named("basic") RepositoryConnectorFactory basic) {
>         Set<RepositoryConnectorFactory> factories = new HashSet<>();
>         factories.add(basic);
>         return Collections.unmodifiableSet(factories);
>     }
>     @Provides
>     @Singleton
>     Set<TransporterFactory> provideTransporterFactories(@Named("file") TransporterFactory file, @Named("http") TransporterFactory http) {
>         Set<TransporterFactory> factories = new HashSet<>();
>         factories.add(file);
>         factories.add(http);
>         return Collections.unmodifiableSet(factories);
>     }
> } {code}
> This works with either maven-resolver-provider 3.6.0 or downgrading allĀ org.apache.maven.resolver artifacts to 1.3.1.
> It seems as if a similar problem occurred in Idea when setting used Maven version to 3.6.2:
> [https://youtrack.jetbrains.com/issue/IDEA-221882]
> Is this a regression introduced in one of the recent maven-resolver versions?



--
This message was sent by Atlassian Jira
(v8.3.4#803005)