autonomousapps / dependency-analysis-gradle-plugin

Gradle plugin for JVM projects written in Java, Kotlin, Groovy, or Scala; and Android projects written in Java or Kotlin. Provides advice for managing dependencies and other applied plugins
Apache License 2.0
1.66k stars 116 forks source link

thinks I can remove testImplementation after adding compileOnly #1149

Open xenoterracide opened 3 months ago

xenoterracide commented 3 months ago

Build scan link https://scans.gradle.com/s/w4puysfgcc2ms

Plugin version 1.3.0

Gradle version

------------------------------------------------------------
Gradle 8.6
------------------------------------------------------------

Build time:   2024-02-02 16:47:16 UTC
Revision:     d55c486870a0dc6f6278f53d21381396d0741c6e

Kotlin:       1.9.20
Groovy:       3.0.17
Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM:          21.0.2 (Eclipse Adoptium 21.0.2+13-LTS)
OS:           Linux 6.6.19-1-MANJARO amd64

(Optional) reason output for bugs relating to incorrect advice

Calculating task graph as configuration cache cannot be reused because file 'build.gradle.kts' has changed.
Type-safe project accessors is an incubating feature.
> Task :buildSrc:checkKotlinGradlePluginConfigurationErrors
> Task :buildSrc:generateExternalPluginSpecBuilders UP-TO-DATE
> Task :buildSrc:extractPrecompiledScriptPluginPlugins UP-TO-DATE
> Task :buildSrc:compilePluginsBlocks UP-TO-DATE
> Task :buildSrc:generatePrecompiledScriptPluginAccessors UP-TO-DATE
> Task :buildSrc:generateScriptPluginAdapters UP-TO-DATE
> Task :buildSrc:compileKotlin UP-TO-DATE
> Task :buildSrc:compileJava NO-SOURCE
> Task :buildSrc:compileGroovy NO-SOURCE
> Task :buildSrc:pluginDescriptors UP-TO-DATE
> Task :buildSrc:processResources UP-TO-DATE
> Task :buildSrc:classes UP-TO-DATE
> Task :buildSrc:jar UP-TO-DATE
> Task :jpa:processResources NO-SOURCE
> Task :jpa:processTestFixturesResources NO-SOURCE
> Task :jpa:findDeclaredProcsMain UP-TO-DATE
> Task :jpa:serviceLoaderMain UP-TO-DATE
> Task :jpa:findDeclarations UP-TO-DATE
> Task :jpa:findDeclaredProcsTest UP-TO-DATE
> Task :jpa:artifactsReportMain UP-TO-DATE
> Task :jpa:explodeCodeSourceTest UP-TO-DATE
> Task :jpa:explodeCodeSourceMain UP-TO-DATE
> Task :jpa:explodeCodeSourceTestFixtures UP-TO-DATE
> Task :jpa:findDeclaredProcsTestFixtures UP-TO-DATE
> Task :jpa:explodeJarMain UP-TO-DATE
> Task :jpa:compileJava UP-TO-DATE
> Task :jpa:findInlineMembersMain UP-TO-DATE
> Task :jpa:graphViewMain UP-TO-DATE
> Task :jpa:graphViewTestFixtures UP-TO-DATE
> Task :jpa:graphViewTest UP-TO-DATE
> Task :jpa:classes UP-TO-DATE
> Task :jpa:abiAnalysisMain UP-TO-DATE
> Task :jpa:explodeByteCodeSourceMain UP-TO-DATE
> Task :jpa:synthesizeDependenciesMain UP-TO-DATE
> Task :jpa:jar UP-TO-DATE
> Task :jpa:synthesizeProjectViewMain UP-TO-DATE
> Task :jpa:compileTestFixturesJava NO-SOURCE
> Task :jpa:serviceLoaderTestFixtures UP-TO-DATE
> Task :jpa:testFixturesClasses UP-TO-DATE
> Task :jpa:artifactsReportTestFixtures UP-TO-DATE
> Task :jpa:computeActualUsageMain UP-TO-DATE
> Task :jpa:explodeJarTestFixtures UP-TO-DATE
> Task :jpa:abiAnalysisTestFixtures UP-TO-DATE
> Task :jpa:testFixturesJar UP-TO-DATE
> Task :jpa:explodeByteCodeSourceTestFixtures UP-TO-DATE
> Task :jpa:findInlineMembersTestFixtures UP-TO-DATE
> Task :jpa:compileTestJava UP-TO-DATE
> Task :jpa:synthesizeDependenciesTestFixtures UP-TO-DATE
> Task :jpa:artifactsReportTest UP-TO-DATE
> Task :jpa:serviceLoaderTest UP-TO-DATE
> Task :jpa:explodeByteCodeSourceTest UP-TO-DATE
> Task :jpa:synthesizeProjectViewTestFixtures UP-TO-DATE
> Task :jpa:explodeJarTest UP-TO-DATE
> Task :jpa:synthesizeProjectViewTest UP-TO-DATE
> Task :jpa:findInlineMembersTest UP-TO-DATE
> Task :jpa:computeActualUsageTestFixtures UP-TO-DATE
> Task :jpa:synthesizeDependenciesTest UP-TO-DATE
> Task :jpa:computeActualUsageTest UP-TO-DATE
> Task :jpa:computeAdvice UP-TO-DATE
> Task :jpa:filterAdvice FROM-CACHE

> Task :jpa:reason

----------------------------------------
You asked about the dependency 'com.xenoterracide:tools:0.0.0-SNAPSHOT (libs.java.tools)'.
You have been advised to remove this dependency from 'testImplementation'.
----------------------------------------

Shortest path from :jpa to com.xenoterracide:tools:0.0.0-SNAPSHOT (libs.java.tools) for compileClasspath:
:jpa
\--- com.xenoterracide:tools:0.0.0-SNAPSHOT

There is no path from :jpa to com.xenoterracide:tools:0.0.0-SNAPSHOT (libs.java.tools) for runtimeClasspath


Shortest path from :jpa to com.xenoterracide:tools:0.0.0-SNAPSHOT (libs.java.tools) for testCompileClasspath:
:jpa
\--- com.xenoterracide:tools:0.0.0-SNAPSHOT

Shortest path from :jpa to com.xenoterracide:tools:0.0.0-SNAPSHOT (libs.java.tools) for testRuntimeClasspath:
:jpa
\--- com.xenoterracide:tools:0.0.0-SNAPSHOT

There is no path from :jpa to com.xenoterracide:tools:0.0.0-SNAPSHOT (libs.java.tools) for testFixturesCompileClasspath


There is no path from :jpa to com.xenoterracide:tools:0.0.0-SNAPSHOT (libs.java.tools) for testFixturesRuntimeClasspath


Source: main
------------
* Uses 1 class: com.xenoterracide.tools.java.annotation.Initializer (implies implementation).

Source: test
------------
* Uses 1 class: com.xenoterracide.tools.java.function.PredicateTools (implies testImplementation).

Source: testFixtures
--------------------
(no usages)

BUILD SUCCESSFUL in 1s
53 actionable tasks: 2 executed, 1 from cache, 50 up-to-date
Configuration cache entry stored.

Describe the bug

The @Initializer is only needed at compile time, so I set my library as compileOnly but PredicateTools which is part of the same library is actually runtime and I added it for use as testImplementation

To Reproduce

I suppose you could add my library to a project, here's the annotation

https://github.com/xenoterracide/java-commons/blob/main/module/tools/src/main/java/com/xenoterracide/tools/java/annotation/Initializer.java

here's the failing build https://github.com/xenoterracide/spring-app-commons/actions/runs/8382923636/job/22957653966

In order to use the latter repo you'll need to set up github credentials gradle.properties

ghUsername=<your gh user>
ghPassword=<a class pat that can read packages>

Expected behavior

no error

Additional context

vicky17d commented 1 month ago

Facing the same issue