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

JPMS #1209

Open xenoterracide opened 5 days ago

xenoterracide commented 5 days ago

Is your feature request related to a problem? Please describe.

java module (module-info) should agree with the gradle dependencies, for example compileOnlyApi should generally match requires static transitive

I suspect this is a bidirectional thing though. For example if I have exports com.myorg.foo but do not have exports com.myorg.foo.internal then even if something that would normally be detected as api should not be api.

if possible, opens... to specifications should possibly be determined, I suspect this would require looking at tests though.

I hope this is clearer than mud.

cc: @jjohannes you might be interested in this issue, or have ideas/suggestions

Vampire commented 3 days ago

At least the dependency consistency check would really be helpful, so that implementation => requires api => requires transitive compileOnly => requires static compileOnlyApi => requires static transitive

Not sure about runtimeOnly, but they might need to be absent in module-info.

xenoterracide commented 2 days ago

AFAIK runtime only dependencies should be excluded from module-info.

There's one exception to things being added to module-info that I've found though. java jdk namespaced modules may need to be listed in a module-info even if no direct abi dependency exists. This is because automatic modules can access everything and do not define which modules they require (static or otherwise). I've run into spring boot issues where I needed to add java.sql to my dependencies. I also ran into a spring boot triggered issue where it tried to load mockito even though I wasn't using it at all, just because it was on the classpath, and that triggered a mockito bug where it requires jdk.agent. So essentially any false positives on java/jdk should be ignored.