Description
EDIT by @nedtwigg: summarizing the current situation, easy workaround, and a hard-to-implement potential fix:
If you use googleJavaFormat()
or removeUnusedImports()
, and you also use cutting edge java language features such as the Java 15 text blocks, then you must also run your build on JRE 15+ (same for language features in any other release, e.g. must use JRE 14+ to use Java 14 language features, etc.). This is because google-java-format
selects which JLS specification to use based on which version of JVM it is running on.
The easy solution is to run your build with a JVM at least as new as the code you are formatting. The hard solution is to add a feature to Spotless which allows forking a more modern JVM just to run formatting. Happy to take a PR for this feature, but we have no plans to implement the feature ourselves.
When trying to use removeUnusedImports
with a Java file that contains a Java 15 text block, the following exception is thrown:
https://ge.junit.org/s/5jcvukwcdcckg/console-log?task=:junit-jupiter-engine:spotlessJava