apache / apache/maven-dependency-plugin

[MDEP-556] The dependency:resolve goal tries to resolve all dependencies, regardless of the exclude filters

Open
#992 0 comments 0 reactions 0 assignees View on GitHub
bug priority:major
Dominant language
Java
Stars
175
Forks
196
Avg merge
19h 30m
Merged PRs (30d)
5

Description

**[Yoann Rodière](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=yrodiere)** opened **[MDEP-556](https://issues.apache.org/jira/browse/MDEP-556?redirect=false)** and commented

My use case was to download dependencies in a CI script, before executing the build. To that end, I wanted to execute something along the lines of:

```
mvn -q -B dependency:resolve -DexcludeArtifactIds='hibernate-search-integrationtest-wildfly'
```

... `hibernate-search-integrationtest-wildfly` being a module that other modules in my project depend on.

But I get this stacktrace:

```
[ERROR] Failed to execute goal on project hibernate-search-performance: Could not resolve dependencies for project org.hibernate:hibernate-search-performance:jar:5.8.0-SNAPSHOT: Cannot access jboss-public-repository-group (https://repository.jboss.org/nexus/content/groups/public-jboss/) in offline mode and the artifact org.hibernate:hibernate-search-integrationtest-wildfly:jar:tests:5.8.0-SNAPSHOT has not been downloaded from it before. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project hibernate-search-performance: Could not resolve dependencies for project org.hibernate:hibernate-search-performance:jar:5.8.0-SNAPSHOT: Cannot access jboss-public-repository-group (https://repository.jboss.org/nexus/content/groups/public-jboss/) in offline mode and the artifact org.hibernate:hibernate-search-integrationtest-wildfly:jar:tests:5.8.0-SNAPSHOT has not been downloaded from it before.
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:221)
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies(LifecycleDependencyResolver.java:127)
at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved(MojoExecutor.java:245)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:199)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project org.hibernate:hibernate-search-performance:jar:5.8.0-SNAPSHOT: Cannot access jboss-public-repository-group (https://repository.jboss.org/nexus/content/groups/public-jboss/) in offline mode and the artifact org.hibernate:hibernate-search-integrationtest-wildfly:jar:tests:5.8.0-SNAPSHOT has not been downloaded from it before.
at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:211)
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:195)
... 23 more
Caused by: org.eclipse.aether.resolution.DependencyResolutionException: Cannot access jboss-public-repository-group (https://repository.jboss.org/nexus/content/groups/public-jboss/) in offline mode and the artifact org.hibernate:hibernate-search-integrationtest-wildfly:jar:tests:5.8.0-SNAPSHOT has not been downloaded from it before.
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:384)
at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:205)
... 24 more
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Cannot access jboss-public-repository-group (https://repository.jboss.org/nexus/content/groups/public-jboss/) in offline mode and the artifact org.hibernate:hibernate-search-integrationtest-wildfly:jar:tests:5.8.0-SNAPSHOT has not been downloaded from it before.
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:367)
... 25 more
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Cannot access jboss-public-repository-group (https://repository.jboss.org/nexus/content/groups/public-jboss/) in offline mode and the artifact org.hibernate:hibernate-search-integrationtest-wildfly:jar:tests:5.8.0-SNAPSHOT has not been downloaded from it before.
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:391)
... 27 more
Caused by: org.eclipse.aether.transfer.RepositoryOfflineException: Cannot access jboss-public-repository-group (https://repository.jboss.org/nexus/content/groups/public-jboss/) in offline mode
at org.eclipse.aether.internal.impl.DefaultOfflineController.checkOffline(DefaultOfflineController.java:72)
at org.eclipse.aether.internal.impl.Utils.checkOffline(Utils.java:115)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:387)
... 27 more
```

I think I know why this fails: when one executes the `dependency:resolve` goal, there is a first dependency resolution requested by the mojo executor, because [the resolve mojo is marked as requiring resolution of test-scoped dependencies](https://github.com/apache/maven-plugins/blob/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java#L42).
I am not sure why the `dependency:resolve` mojo would require this, though... It seems odd, considering that the purpose of this mojo is to perform dependency resolution.

---

**Affects:** 3.0.0

1 votes, 2 watchers

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with ResolveDependenciesMojo.java, especially the requirement for test-scoped dependency resolution linked in the issue, and trace how Maven invokes dependency:resolve before the mojo runs. Reproduce the command with the excludeArtifactIds option; done means excluded artifacts are not resolved while the requested dependencies still are.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.