-
Notifications
You must be signed in to change notification settings - Fork 460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
google-java-format (and removeUnusedImports) broken on JDK 16+ (has workaround) #834
google-java-format (and removeUnusedImports) broken on JDK 16+ (has workaround) #834
Comments
I think this can be worked-around if we somehow add these flags to the JVM which runs Gradle.
The deeper fix will be related to #724. |
This can be done in maven via |
@nedtwigg The following can be added to your
|
- update gradle.properties for spotless jdk16 work around - diffplug/spotless#834
Edit: Nevermind! I had an override of jvmargs in my gradle home that was overridding this |
I tried playing with the Worker API for running Spotless. As a PoC, I could get https://github.com/diffplug/spotless/compare/main...anuraaga:worker?expand=1 It was nice seeing how so much of the configuration is serializable, presumably to satisfy Gradle cache, which is a requirement for the Worker API. However, not all of it is, for example https://github.com/diffplug/spotless/compare/main...anuraaga:worker?expand=1#diff-fb99f7a4cb3e09aa538ffb82c60c7119d0eddfb92fd93af98cb6337df1e87476R47 Can any team member skim through that PR to see if it seems feasible at all? If it is I can continue with it but it's quite invasive so want to get a sanity check first. |
Thanks for the investigation! It is promising. In your draft, there are a few places where a The root of this problem is I think there are two different, but not exactly mutually exclusive paths forward:
If you are interested in continuing the experiment, open a draft PR and we can continue from there. These improvements are also on the path to properly supporting the Gradle configuration cache. |
* The workaround to make google-java-format work described in diffplug/spotless#834 requires raising the minimum build requirement to JDK 11. * Runtime compatibility with JDK 8 is ensured by using the '--release' compiler flag.
As explained in the [spotless issue tracker](diffplug/spotless#834), there is an outstanding issue with the google formatter depending on JDK internals. We add the flags listed there to avoid module errors when running spotless. After upgrading and rerunning `spotlessApply`, several stray semicolons became apparent and have now been removed.
* Bump JDA version to 324 (#31) Updates JDA (they forgot something with slash-commands, has been added now) * Add spotless integration This hopefully makes formatting more consistent. The Eclipse XML style was chosen as it is understood by Eclipse, VSC (JDT), Spotless and mostly by IntelliJ. * Make gradelew executable * Add "Remove unused imports" setting to spotless Co-authored-by: Marko Radosavljević <[email protected]> * Remove unused imports to fix diffplug/spotless#834 (#35) Co-authored-by: I-Al-Istannen <[email protected]> Co-authored-by: Marko Radosavljević <[email protected]> Co-authored-by: Jonas <[email protected]>
It is worth being wary of doing this, since passing these flags will cause javac for JDK 1.8 to fail, as the flags are unsupported. |
Fixes same problem as deepjavalibrary/djl-serving#184 using workaround described in diffplug/spotless#834 and found in https://github.com/diffplug/spotless/tree/main/plugin-gradle#google-java-format.
Fixes #184 Uses workaround described in diffplug/spotless#834 and found in https://github.com/diffplug/spotless/tree/main/plugin-gradle#google-java-format.
See diffplug/spotless#834 Signed-off-by: Jan N. Klug <[email protected]>
Fixes same problem as deepjavalibrary/djl-serving#184 using workaround described in diffplug/spotless#834 and found in https://github.com/diffplug/spotless/tree/main/plugin-gradle#google-java-format.
Read more about the spotless fix here diffplug/spotless#834
See diffplug/spotless#834 Signed-off-by: Jan N. Klug <[email protected]>
See diffplug/spotless#834 Signed-off-by: Jan N. Klug <[email protected]>
See diffplug/spotless#834 Signed-off-by: Jan N. Klug <[email protected]>
* Raise source level to Java 17 (except for model classes) * Remove Nashorn script engine * Upgrade spotless and add jvm options See diffplug/spotless#834 * Add suppression for findBugs false positive error * Upgrade xtext to 2.29.0 * Adjust JNA * Resolve itests Signed-off-by: Jan N. Klug <[email protected]>
* Raise source level to Java 17 (except for model classes) * Remove Nashorn script engine * Upgrade spotless and add jvm options See diffplug/spotless#834 * Add suppression for findBugs false positive error * Upgrade xtext to 2.29.0 * Adjust JNA * Resolve itests Signed-off-by: Jan N. Klug <[email protected]> GitOrigin-RevId: 41ba3ff
Is there any way to resolve this without updating gradle.proerties file with below |
@poojaverma009 upgrade to the latest Spotless. It's resolved. |
I am trying to update my project from jdk version 11 to 17 but I am getting below error |
@poojaverma009 which version of spotless do you use? |
spotlessVersion = '5.14.3' |
This is fixed by #1224 and #1228 so use a version >= 6.7.1 should work. This is what I mean by:
|
Thanks |
When running under JDK 16 I get this error message:
EDIT:
EDIT 2 & 3
plugin-gradle 6.5.1
andplugin-maven 2.22.3
, but that was incorrect, the workaround is still requiredThe text was updated successfully, but these errors were encountered: