apache / apache/maven

[MNG-1378] Make dependencies of test-jars transitive

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

Description

**[Mark Hobson](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=mihobson)** opened **[MNG-1378](https://issues.apache.org/jira/browse/MNG-1378?redirect=false)** and commented

test-jar transitive dependencies are calculated as per compile scope rather than test scope.

The situation is demonstrated nicely in it0077:

* module sub1 has a test-scoped dependency of commons-lang
* module sub2 has a test-scoped dependency of sub1 test-jar

sub2 tests should inherit the commons-lang transitive dependency. For example:

Index: maven-core-it/it0077/sub2/src/test/java/org/apache/maven/it0077/PersonTwoTest.java

---

--- maven-core-it/it0077/sub2/src/test/java/org/apache/maven/it0077/PersonTwoTest.java (revision
328307)
+++ maven-core-it/it0077/sub2/src/test/java/org/apache/maven/it0077/PersonTwoTest.java (working
copy)
@@ -1,6 +1,7 @@
package org.apache.maven.it0077;

import junit.framework.TestCase;
+import org.apache.commons.lang.BooleanUtils;

public class PersonTwoTest
extends PersonTest

Results in:

[INFO] ----------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ----------------------------------------------------------------------------
[INFO] Compilation failure

c:\maven-components\maven-core-it\it0077\sub2\src\test\java\org\apache\maven\it0077\PersonTwoTest.java:[4,31]
package org.apache.commons.lang does not exist

---

**Affects:** 2.0

**Attachments:**
- [mng1378.tar.gz](https://issues.apache.org/jira/secure/attachment/12712862/mng1378.tar.gz) (_1.53 kB_)

**Issue Links:**
- [MNG-1921](https://issues.apache.org/jira/browse/MNG-1921) test scope in dependencyManagement does not appear to be transitive to dependent subProjects
(_**"is duplicated by"**_)
- [MNG-2975](https://issues.apache.org/jira/browse/MNG-2975) test scope does not work with pom dependency
(_**"is duplicated by"**_)
- [MNG-2035](https://issues.apache.org/jira/browse/MNG-2035) Add transitive dependencies with test scope when depending on a test-jar type dependency
(_**"is duplicated by"**_)
- [MNG-5621](https://issues.apache.org/jira/browse/MNG-5621) Transitive dependency for both compile and test
(_**"is duplicated by"**_)
- [MNG-5739](https://issues.apache.org/jira/browse/MNG-5739) Adding a test dependency can move dependencies from the compile scope to the test scope

- [MNG-6224](https://issues.apache.org/jira/browse/MNG-6224) Dependency version from test scope leaks into compile scope

- [MNG-1571](https://issues.apache.org/jira/browse/MNG-1571) Wrong calculation of transient dependecies if artifact is referenced from different scopes

- [MNG-1971](https://issues.apache.org/jira/browse/MNG-1971) Transitive dependencies not following attached tests.

- [MNG-1823](https://issues.apache.org/jira/browse/MNG-1823) dependencies with classifier mask transitive dependencies of same dependency without classifier
(_**"is depended upon by"**_)

71 votes, 77 watchers

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.