[ 
https://issues.apache.org/jira/browse/MDEP-791?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17494965#comment-17494965
 ] 

Elliotte Rusty Harold commented on MDEP-791:
--------------------------------------------

Using the test project linked above (MDEP-791.zip) I failed to reproduce this. 
Everything worked exactly as I expected,both on compile and analysis. I did 
have to change the compiler version to 1.8 in case that's significant. To be 
specific:

    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
      <version>${jackson.version}</version>
      <scope>compile</scope>
    </dependency>

caused 

[WARNING] Non-test scoped test only dependencies found:
[WARNING]    com.fasterxml.jackson.core:jackson-core:jar:2.13.1:compile

and 

    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
      <version>${jackson.version}</version>
      <scope>test</scope>
    </dependency>

fixed this to get:

[INFO] --- maven-dependency-plugin:3.3.0-SNAPSHOT:analyze (default-cli) @ tstp 
---
[INFO] No dependency problems found

and did not break the build. mvn compile still worked. For the record

elharo-macbookpro1:tj elharo$ mvn -v
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /opt/java/maven
Java version: 1.8.0_302, vendor: Azul Systems, Inc., runtime: 
/Users/elharo/.sdkman/candidates/java/8.0.302-zulu/zulu-8.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"

As of now I am unconvinced there is any bug to be fixed around this, either in 
the dependency analyzer, plugin, or maven resolution. This is, of course, 
subject to revision on more evidence. However right now it seems that if there 
is an issue here, it  is more subtle and specific than we yet understand. 

> Non-test scoped and transitive dependencies in compile scope
> ------------------------------------------------------------
>
>                 Key: MDEP-791
>                 URL: https://issues.apache.org/jira/browse/MDEP-791
>             Project: Maven Dependency Plugin
>          Issue Type: Bug
>    Affects Versions: 3.2.0, 3.3.0
>            Reporter: Slawomir Jaranowski
>            Priority: Critical
>         Attachments: MDEP-791.zip
>
>
> When we use some dependency in test classes which is not used in production 
> code but is required as transitive dependency for other used in production 
> code - such dependency should not be included in {*}{{Non-test scoped}}{*}.
> Example:
>  * test code use {{ObjectCodec}} from {{jackson-core}}
>  * production code use only {{ObjectMapper}} from {{jackson-databind}}
>  * production code don't use any classes from {{jackson-core}}
> {{jackson-core}} is needed by {{jackson-databind}} and must by in compile 
> scope so should not be reported as {{Non-test scoped}}
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to