Closed xenoterracide closed 7 months ago
I wonder if this is related to the fact that we put JSpecify's module-info
under the mrjar root:
$ jar -tf $HOME/.m2/repository/org/jspecify/jspecify/0.3.0/jspecify-0.3.0.jar | grep module-info
META-INF/versions/9/module-info.class
I would like to think that tools would support it in that location. But we could investigate moving it back. We could probably test that by building after tweaking this line, but I don't know enough Gradle offhand to be confident I could pull off that and especially a retest using the new jar in 5 minutes :)
@cpovirk what jspecify
does is correct. Gradle finds the module-info.class
in META-INF/version/*
.
@xenoterracide The problem is an inconsistency between the dependencies declared in Gradle and the requires directives in module-info in your project. It says
requires org.jspecify;
...in the module-info.
But
compileOnlyApi(libs.jspecify)
...in the build.gradle.kts.
It should hence be requires static transitive org.jspecify;
in the module-info. Right now the jspecify
module is expected by Java at runtime (as there is no static
) but it is not put on the runtime path due to the compileOnlyApi scope in Gradle.
Hint: You may checkout our java-module-dependencies plugin, which exists for the very reason to avoid such inconsistencies by removing the redundancy caused by having to declare dependency scopes in both Java and Gradle.
Could it maybe throw a better error than this?
so, after this, and much more playing... it's interesting, whitebox seems to explode if I don't use compileOnlyApi(libs.jspecify)
, compileOnly
doesn't work. There's no difference though whether I use require static
vs require transient static
, with whitebox or blackbox testing. I refreshed myself on the difference.
> Task :tools:compileTestJava FAILED
error: module not found: org.jspecify
1 error
I mean, that error by itself makes sense, except I'm not requesting it..
as an asside I'm not actually certain whether a type annotation library like jspecify, or jetbrains annotations should be compileOnly
or compileOnlyApi
although I've noticed with non JPMS projects I often end up with compile time warnings from annotations that where types on properties that they have are missing (spring, it's always spring-*).
everything is here https://github.com/xenoterracide/java-commons/pull/43/commits/82542fb1252cc2eceb19ec5212b8a6cf50f5ed2e