maven-dependency-plugin icon indicating copy to clipboard operation
maven-dependency-plugin copied to clipboard

[MDEP-977] Incorrect handling if transitive compile dependency is used in tests

Open jira-importer opened this issue 9 months ago • 0 comments

Jakub Bochenski opened MDEP-977 and commented

PostgreSQLContainer extends GenericContainer which is a FailureDetectingExernalResource which then implements org.junit.rules.TestRule.

I think the case when you use Testcontainers in your main sources, while also have JUnit tests in your test sources is not handled correctly:

If you declare in pom.xml

<dependency>
    <groupId>org.testcontainers</groupId>
    <artifactId>postgresql</artifactId>
</dependency>
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
</dependency>
<dependency>
    <groupId>org.testcontainers</groupId>
    <artifactId>testcontainers</artifactId>
</dependency>

then the analyze will fail with:

[INFO] --- dependency:3.8.1:analyze-only (analyze-only) @ persistence-test ---
[ERROR] Non-test scoped test only dependencies found:
[ERROR]    junit:junit:jar:4.13.2:compile

This is wrong - Junit needs to be in compile scope because of the Testcontainers classes extending it.


Affects: 3.8.1

jira-importer avatar Feb 19 '25 17:02 jira-importer