./gradlew spotlessGroovy fails when containing Closure like () -> {}
- 主要言語
- Java
- スター
- 5.6k
- フォーク
- 559
- 平均マージ
- 1日 14時間
- マージ済み PR(30日)
- 43
説明
## Summary
`./gradlew spotlessGroovy` fails on the following simple groovy code.
```groovy
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
```sh
% 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)
```
```sh
% ./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
コントリビューションガイド
調査の方向性
示されている greclipse 設定を使って ./gradlew spotlessGroovy を実行し、サンプルの Groovy クラスで失敗を再現してから、stack trace で示された formatter の経路を調べます。() -> {} と書かれた Groovy closure をコマンドが受け付けてフォーマットし、unexpected-token error を発生させなければ完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- groovy, java
- 領域
- build-system
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100