apache / apache/maven-assembly-plugin
[MASSEMBLY-894] Test scope dependency causes compile time dependency to be excluded
- Dominant language
- Java
- Stars
- 110
- Forks
- 75
- Avg merge
- 12h 54m
- Merged PRs (30d)
- 10
Description
**[Jeff Evans](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=jeff.w.evans)** opened **[MASSEMBLY-894](https://issues.apache.org/jira/browse/MASSEMBLY-894?redirect=false)** and commented
Consider the following dependencies
* `moduleA` depends on moduleB, at `compile` scope, which in turn depends on `libraryX`, also at `compile` scope
* `moduleA` also depends on `libraryX directly`, but at a `test` scope
In this scenario, when defining a `dependencySet` to capture the `runtime` dependencies of moduleA, I would expect libraryX to be included, but it seems it's not. That's because the `test` scope we use directly in `moduleA` is overriding the `compile` scope from `moduleB`. I would think that the dependency should be included, as its a compile (and thus runtime) dependency of moduleB, and therefore of moduleA itself, even though it's not a compile time dependency of moduleA directly. Moreover, since the direct dependency from moduleA is at a test scope, it should be completely ignored by the plugin, which should be only looking at `runtime` scope.
I have created a sample project to illustrate this behavior [here](https://github.com/jeff303/maven-assembly-plugin-issues). If you run `mvn clean package`, the `jackson-core` jars (and others) do not end up in the final distribution. I observed this behavior in version 2.6 of the plugin, but also tried with 3.1.0 and saw the same (although the debug output differed somewhat). If you change the scope on line 76 of the root `pom.xml` file to `compile` instead, then it works as expected.
---
**Affects:** 3.1.0
**Issue Links:**
- [MASSEMBLY-1008](https://issues.apache.org/jira/browse/MASSEMBLY-1008) Assembly plugin handles scopes wrongly
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the linked sample project and run `mvn clean package` to reproduce the missing jackson-core jars in the final distribution. Inspect the root `pom.xml` dependency scope on line 76 and the assembly `dependencySet` configuration, then verify that runtime output retains transitive compile dependencies while ignoring the direct test-scoped dependency.
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