apache / apache/maven

[MNG-8074] test-jar artifacts should not be resolved when maven.test.skip is enabled

Open
#10,851 0 comments 0 reactions 0 assignees View on GitHub
bug priority:minor
Dominant language
Java
Stars
5.3k
Forks
3.1k
Avg merge
20h 42m
Merged PRs (30d)
297

Description

**[Daniel Puiu](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=JIRAUSER285001)** opened **[MNG-8074](https://issues.apache.org/jira/browse/MNG-8074?redirect=false)** and commented

When passing maven.test.skip to a Maven build, Maven will try to resolve test-jar artifacts from local repo or Nexus. If missing the build fails.

Maven should remove test-jar dependencies from dependencies when maven.test.skip is passed.

I have created a small multimodule project (attached) to replicate the issue. Parent contains common and core modules.

Common is producing a test-jar. Core has a test dependency on common test-jar.

When running "mvn clean install -Dmaven.test.skip" the build fails with the following error:

```
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for maven-bug-test-jar 1.0.0-SNAPSHOT:
[INFO]
[INFO] maven-bug-test-jar ................................. SUCCESS [  1.778 s]
[INFO] common ............................................. SUCCESS [  6.152 s]
[INFO] core ............................................... FAILURE [  0.222 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  8.217 s
[INFO] Finished at: 2024-03-11T11:22:45+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project core: Could not resolve dependencies for project org.example:core:jar:1.0.0-SNAPSHOT: The following artifacts could not be resolved: org.exa
mple:common:jar:tests:1.0.0-SNAPSHOT (absent): Could not find artifact org.example:common:jar:tests:1.0.0-SNAPSHOT -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn -rf :core
```

I have tested the issue with maven-jar-plugin:3.3.0 and maven 3.9.6.

---

**Attachments:**
- [maven-bug-test-jar.zip](https://issues.apache.org/jira/secure/attachment/13067378/maven-bug-test-jar.zip) (_4.48 kB_)

Contributor guide

Open the contributing guide

Research direction

Start by running the attached multimodule reproduction with `mvn clean install -Dmaven.test.skip` and confirm that the core module tries to resolve the common test-jar. Trace Maven's dependency-resolution path for test-jar dependencies, then add regression coverage showing that the command succeeds without resolving them.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.