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

Richard Eckart de Castilho edited comment on MDEP-757 at 3/17/23 9:42 AM:
--------------------------------------------------------------------------

Here is another reproducer.

* Either maven-dependency-plugin complains about 
{noformat}
[ERROR] Non-test scoped test only dependencies found:
[ERROR]    example:library:jar:0.0.1-SNAPSHOT:compile
{noformat}
* or if I make the dependency a test dependency, then the compiler complains:
{noformat}
[ERROR] Failed to execute goal 
org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on 
project consumer: Compilation failure
[ERROR] 
.../root/consumer/src/main/java/consumer/ActualImplementationClass.java:[8,23] 
cannot access library.LibraryObject
[ERROR]   class file for library.LibraryObject not found
{noformat}

 [^MDEP-757-reproducer-2-rec.zip]

It works ok with {{library}} as a {{test}} as long as 
{{ActualImplementationClass}} is not calling the 
{{AbstractBaseClass.getObject()}} method - but once that method call is added, 
the compiler fails.

Looking into the analyzer source code, it appears that the analysis only 
considers surface properties like method signatures, but does not seem to check 
what is done inside the methods.


was (Author: rec):
Here is another reproducer.

* Either maven-dependency-plugin complains about 
{noformat}
[ERROR] Non-test scoped test only dependencies found:
[ERROR]    example:library:jar:0.0.1-SNAPSHOT:compile
{noformat}
* or if I make the dependency a test dependency, then the compiler complains:
{noformat}
[ERROR] Failed to execute goal 
org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on 
project consumer: Compilation failure
[ERROR] 
.../root/consumer/src/main/java/consumer/ActualImplementationClass.java:[8,23] 
cannot access library.LibraryObject
[ERROR]   class file for library.LibraryObject not found
{noformat}

 [^MDEP-757-reproducer-2-rec.zip] 

> bug with "non-test scoped test only dependencies found"
> -------------------------------------------------------
>
>                 Key: MDEP-757
>                 URL: https://issues.apache.org/jira/browse/MDEP-757
>             Project: Maven Dependency Plugin
>          Issue Type: Bug
>          Components: analyze
>    Affects Versions: 3.2.0
>         Environment: mvn --version
> Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
> Maven home: /usr/local/Cellar/maven/3.8.1/libexec
> Java version: 11.0.11, vendor: AdoptOpenJDK, runtime: 
> /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
> Default locale: en_US, platform encoding: UTF-8
> OS name: "mac os x", version: "11.4", arch: "x86_64", family: "mac"
>            Reporter: Henning Schmiedehausen
>            Assignee: Henning Schmiedehausen
>            Priority: Major
>         Attachments: MDEP-757-reproducer-2-rec.zip
>
>
> Starting with 3.2.0, I see this problem in one of my project modules:
> {noformat}
> [INFO] --- maven-dependency-plugin:3.2.0:analyze-only (basepom.default) @ 
> foundation ---
> [WARNING] Non-test scoped test only dependencies found:
> [WARNING] com.fasterxml.jackson.core:jackson-databind:jar:2.12.2:compile
> {noformat}
> This is not correct:
> {noformat}
> % cd lib/foundation
> % grep -r databind src/main
> src/main/java/dev/data/DataSet.java:import 
> com.fasterxml.jackson.databind.annotation.JsonDeserialize;
> src/main/java/dev/data/DataSet.java:import 
> com.fasterxml.jackson.databind.annotation.JsonSerialize;
> src/main/java/dev/data/WriteableLocator.java:import 
> com.fasterxml.jackson.databind.annotation.JsonSerialize;
> src/main/java/dev/data/ObjectMetadata.java:import 
> com.fasterxml.jackson.databind.annotation.JsonDeserialize;
> src/main/java/dev/data/ObjectMetadata.java:import 
> com.fasterxml.jackson.databind.annotation.JsonSerialize;
> src/main/java/dev/data/DataDefinition.java:import 
> com.fasterxml.jackson.databind.annotation.JsonSerialize;
> src/main/java/dev/data/ObjectAttribute.java:import 
> com.fasterxml.jackson.databind.annotation.JsonDeserialize;
> src/main/java/dev/data/ObjectAttribute.java:import 
> com.fasterxml.jackson.databind.annotation.JsonSerialize;
> src/main/java/dev/data/ObjectDefinition.java:import 
> com.fasterxml.jackson.databind.annotation.JsonDeserialize;
> src/main/java/dev/data/ObjectDefinition.java:import 
> com.fasterxml.jackson.databind.annotation.JsonSerialize;
> src/main/java/dev/data/ImmutableDataObject.java:import 
> com.fasterxml.jackson.databind.annotation.JsonSerialize;
> {noformat}
> So this dependency is used all over the place in the main sources (which is 
> why it can not be in test scope). However, the plugin no longer (it did in 
> 3.1.2) recognize it (all the uses are just annotations, so I guess that is 
> the problem) and raises this error.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to