Closed XiaoPangxie732 closed 3 years ago
Sorry you're having trouble! I'm having difficulty reproducing the issue you're describing.
I tried adding the code you described to a simple sample Gradle project that uses the plugin; you can find that simple project here: https://github.com/kelloggm/sample-gradle-project/tree/repro-cf-gradle-149. When I run ./gradlew clean build
on the project linked above, I get the output:
> Configure project :
Unable to determine Checker Framework version. Assuming default is being used: 3.11.0
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/kelloggm/jsr308/sample-gradle-project/build.gradle' line: 33
* What went wrong:
A problem occurred evaluating root project 'sample-gradle-project'.
> No signature of method: build_22n4gkxop7tl5d7vh5g33jvft.java() is applicable for argument types: (build_22n4gkxop7tl5d7vh5g33jvft$_run_closure3) values: [build_22n4gkxop7tl5d7vh5g33jvft$_run_closure3@62ad181d]
Possible solutions: wait(), any(), wait(long), tap(groovy.lang.Closure), each(groovy.lang.Closure), any(groovy.lang.Closure)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
This output suggests to me that I didn't reproduce the issue you're describing correctly, since the error message indicates that the build file isn't valid. Can you help me produce a valid build file that exhibits this problem, so that I can fix it?
On a theoretical note, I have some suspicions about what might have caused this bug. Without the ability to reproduce it, I can't test them, so what follows is pure speculation. The error message you're seeing definitely suggests a mismatch between the JVM version and the options being passed to the Checker Framework. The option --add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED
is passed by the plugin to the JVM in which the Checker Framework will run if the plugin detects that the JVM is Java9-compatible, according to Gradle's API. It seems to me that you're running a Java 11 JVM in a configuration where it's pretending to be a Java 8 JVM, and thus rejecting the option. One possible solution would be to add an option to the plugin that forces it to assume the underlying JVM is a particular version, rather than relying on the Gradle API; that's not particularly elegant, but I think it would let you work around this particular problem.
I found that you are using Gradle 6.3, the configuration I provided doesn't compatible with Gradle 6.3(toolchain
block is an incubating feature added in Gradle 6.8). You could use Gradle 6.8.3 and try again. And make sure you use JDK 11 to run the script.
@XiaoPangxie732 Sorry for taking some time to get back to you. I was able to reproduce the failure you see using Gradle 6.8.3 - thanks! I've opened a PR (#152) which I hope will fix the bug.
Since it may take some time to merge that PR and release a new version, I also put up a version 0.5.19-SNAPSHOT
that you can use right away to test this on your project. Please let me know if you do and it works (or not!).
Thanks. It works.
System with JDK 11 installed and the following Gradle configuration:
Got this error: