Skip to content

Commit 8465873

Browse files
committed
chore(spotless): Replace greclipse by prettier
1 parent 4a91aa7 commit 8465873

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

build.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import com.diffplug.gradle.spotless.SpotlessExtension
2+
import com.diffplug.spotless.npm.PrettierFormatterStep
23
import datadog.gradle.plugin.ci.testAggregate
34

45
plugins {
@@ -39,10 +40,10 @@ with(extensions["spotlessPredeclare"] as SpotlessExtension) {
3940
googleJavaFormat("1.32.0")
4041
}
4142
groovyGradle {
42-
greclipse()
43+
prettier(mapOf("prettier" to "3.7.4", "prettier-plugin-groovy" to "0.2.1"))
4344
}
4445
groovy {
45-
greclipse()
46+
prettier(mapOf("prettier" to "3.7.4", "prettier-plugin-groovy" to "0.2.1"))
4647
}
4748
kotlinGradle {
4849
ktlint("1.8.0")
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# prettier-groovy.toml
2+
# Reads the .editorconfig file in the project root for base settings
3+
4+
plugins = [
5+
"prettier-plugin-groovy", # https://www.npmjs.com/package/prettier-plugin-groovy
6+
]
7+
8+
[[overrides]]
9+
files = ["*.groovy"]
10+
options = { parser = "groovy" }

gradle/spotless.gradle

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def buildDirectoryFiles = project.layout.buildDirectory.asFileTree
99

1010
spotless {
1111
if (rootProject.hasProperty('skipSpotless')) {
12+
logger.warn("This property is going away, use standard Gradle options: '-x spotlessCheck' or '-x spotlessApply' to exclude spotless tasks")
1213
// Spotless in JDK 8 uses an older eclipse formatter, and it has a (flaky) bug crashing check_profiling.
1314
// We disable it in CI, since we have a job dedicated to spotless anyway.
1415
enforceCheck false
@@ -37,7 +38,7 @@ spotless {
3738
} else {
3839
target '*.gradle'
3940
}
40-
greclipse().configFile(configPath + '/enforcement/spotless-groovy.properties')
41+
prettier(["prettier" : "3.7.4", "prettier-plugin-groovy" : "0.2.1"]).configFile(configPath + '/enforcement/prettier-groovy.toml')
4142
}
4243

4344
kotlinGradle {
@@ -54,13 +55,9 @@ spotless {
5455
project.pluginManager.withPlugin('groovy') {
5556
groovy {
5657
toggleOffOn()
57-
if (!groovySkipJavaExclude) {
58-
excludeJava() // excludes all Java sources within the Groovy source dirs from formatting
59-
// the Groovy Eclipse formatter extends the Java Eclipse formatter,
60-
// so it formats Java files by default (unless `excludeJava` is used).
61-
}
58+
target("**/*.groovy")
6259
targetExclude(buildDirectoryFiles)
63-
greclipse().configFile(configPath + '/enforcement/spotless-groovy.properties')
60+
prettier(["prettier" : "3.7.4", "prettier-plugin-groovy" : "0.2.1"]).configFile(configPath + '/enforcement/prettier-groovy.toml')
6461
}
6562
}
6663

0 commit comments

Comments
 (0)