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

Thorsten Glaser commented on MDEP-753:
--------------------------------------

This is a little tricky.

Some of the other checks also check if the code *directly* uses the Maven 
module, and if not (if only subclasses that are in other modules are used), 
there normally needs to be no direct dependency from your project to the module 
with the parent classes that are not used.

That being said, you say “with test scope, compile fails”. Well, it does not, 
for me:
{noformat}
$ mvn clean test
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------------< mdep753:tstp >----------------------------
[INFO] Building tstp 0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ tstp ---
[INFO] Deleting /home/tglase/tjc/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ tstp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/tglase/tjc/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ tstp ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/tglase/tjc/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ 
tstp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/tglase/tjc/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ tstp 
---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/tglase/tjc/target/test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ tstp ---
[INFO] Surefire report directory: /home/tglase/tjc/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running tstp.TestMDEP753
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.512 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.025 s
[INFO] Finished at: 2022-02-13T19:49:03+01:00
[INFO] ------------------------------------------------------------------------
{noformat}
This is with {{chas.zip}} with only the following change:
{noformat}
--- tj/pom.xml
+++ tjc/pom.xml
@@ -45,8 +45,8 @@
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-core</artifactId>
                        <version>${jackson.version}</version>
-<!--   <scope>test</scope>
-                       with test scope, compile fails
+       <scope>test</scope>
+<!--                   with test scope, compile fails
                        without test scope, dependency check fails
 [INFO] - - - maven-dependency-plugin:3.3.0-SNAPSHOT:analyze-only 
(check-dependencies) @ tstp - - -
 [WARNING] Non-test scoped test only dependencies found:
{noformat}
What do you do differently that it fails “mvn clean test” for you? In case this 
is relevant, I’m using:
{noformat}
$ mvn --version
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 11.0.14, vendor: Debian, runtime: 
/usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "5.10.0-8-amd64", arch: "amd64", family: "unix"
{noformat}
If it failed, I’d agree that this was still unfixed / a bug, but {{mvn clean 
test}} (and {{{}package{}}}) passing is somewhat of the litmus test here… and 
they do, for me.

> Non-test dependency reported as Non-test scoped test only dependency
> --------------------------------------------------------------------
>
>                 Key: MDEP-753
>                 URL: https://issues.apache.org/jira/browse/MDEP-753
>             Project: Maven Dependency Plugin
>          Issue Type: Bug
>          Components: analyze
>    Affects Versions: 3.2.0
>            Reporter: Elliotte Rusty Harold
>            Assignee: Elliotte Rusty Harold
>            Priority: Critical
>             Fix For: 3.3.0
>
>         Attachments: chas.zip, tj.zip
>
>
> Saw this when updating the google-http-java-client from 3.1.2 to 3.2.0 of the 
> plugin. I'm not immediately sure whether this is a regression:
> [INFO] --- maven-dependency-plugin:3.2.0:analyze (default-cli) @ 
> google-http-client ---
> Warning:  Non-test scoped test only dependencies found:
> Warning:     com.google.guava:guava:jar:30.1.1-android:compile
> Warning:     io.opencensus:opencensus-api:jar:0.28.0:compile
> Changing Guava to scope test breaks the build, which is expected based on the 
> code. The warning seems incorrect. 
> https://github.com/googleapis/google-http-java-client/pull/1396
> https://github.com/googleapis/google-http-java-client/pull/1396/checks?check_run_id=2809438131



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

Reply via email to