Re: [maven-resolver] DefaultDependencyCollector not collecting direct provided dependencies

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

Re: [maven-resolver] DefaultDependencyCollector not collecting direct provided dependencies

Tomo Suzuki
I created a test case to demonstrate this behavior:
https://github.com/suztomo/maven-provided-scope/blob/master/src/test/java/suztomo/AppTest.java#L72

On Fri, Feb 7, 2020 at 5:36 PM Tomo Suzuki <[hidden email]> wrote:

>
> Hi Maven developers,
>
> I find DefaultDependencyCollector is not getting "direct" and
> "provided" dependencies by default. Is this expected behavior?
>
> Background:
> We use maven-resolver in our Java code. We create
> RepositorySystemSesison through MavenRepositorySystemUtils.newSession
> [1]. We use the session and DefaultDependencyCollector through
> RepositorySystem.collectDependencies [2] to get the dependency graph
> of a Maven artifact.
>
> Problem:
> The dependency graph from RepositorySystem.collectDependencies does
> not have direct provided dependencies. I expect provided dependencies
> should be included in the graph when they are direct dependencies.
>
> Analysis:
> - MavenRepositorySystemUtils.newSession [3] creates
> ScopedDependencySelector("test", "provided")
> - ScopeDependencySelector.deriveChildSelector [4] creates clone of
> itself with transitive=true. When transitive=true, it does not select
> "provided" dependency.
> - DefaultDependencyCollector.collectDependencies [5] always call
> deriveChildSelector before using the selector from the session.
> - Therefore, ScopeDependencySelector always has transitive=true ( to
> exclude provided dependencies) when it's used with
> DefaultDependencyCollector.
>
> [1]: https://github.com/GoogleCloudPlatform/cloud-opensource-java/blob/50da79355e042c5ff14ec72230cc6edbddcf8436/dependencies/src/main/java/com/google/cloud/tools/opensource/dependencies/RepositoryUtility.java#L112
> [2]: https://github.com/GoogleCloudPlatform/cloud-opensource-java/blob/50da79355e042c5ff14ec72230cc6edbddcf8436/dependencies/src/main/java/com/google/cloud/tools/opensource/dependencies/DependencyGraphBuilder.java#L179
> [3]: https://github.com/apache/maven/blob/master/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java#L102
> [4]: https://github.com/apache/maven-resolver/blob/47edcfe69c4e52ced4cb93d65b7348b5645cdd68/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/ScopeDependencySelector.java#L119
> [5]: https://github.com/apache/maven-resolver/blob/18dd2b5cde851256a9f44db25097efee0691d6b4/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/DefaultDependencyCollector.java#L255
>
> --
> Regards,
> Tomo



--
Regards,
Tomo

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]