spotless
spotless copied to clipboard
./gradlew spotlessGroovy fails when containing Closure like () -> {}
Summary
./gradlew spotlessGroovy fails on the following simple groovy code.
class A {
def closure = () -> { println("Hello") }
}
A part of error:
java.lang.RuntimeException: Snippet9317c627808d48a9aa0df9d7f2ce9fe2.groovy: 2: unexpected token: ) @ line 2, column 17.
def closure = () -> { println("Hello") }
Configuration
plugins {
id("java")
id("groovy")
id("com.diffplug.spotless") version "6.21.0"
}
group = "org.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
testImplementation(platform("org.junit:junit-bom:5.9.1"))
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("org.apache.groovy:groovy-all:4.0.14")
}
tasks.test {
useJUnitPlatform()
}
spotless {
groovy {
greclipse()
}
}
Environment
% java -version
openjdk version "17.0.8" 2023-07-18 LTS
OpenJDK Runtime Environment Corretto-17.0.8.7.1 (build 17.0.8+7-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.8.7.1 (build 17.0.8+7-LTS, mixed mode, sharing)
% ./gradlew --version
------------------------------------------------------------
Gradle 8.2
------------------------------------------------------------
Build time: 2023-06-30 18:02:30 UTC
Revision: 5f4a070a62a31a17438ac998c2b849f4f6892877
Kotlin: 1.8.20
Groovy: 3.0.17
Ant: Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM: 17.0.8 (Amazon.com Inc. 17.0.8+7-LTS)
OS: Mac OS X 13.5.2 aarch64
Stack Trace(./gradlew spotlessApply --stacktrace > out 2>&1)
https://gist.github.com/polyomino24/4cbc3f0900a4dc85577151b70ad97cb8