From ef72acd114655b099ca9146dd65c9d6a0e7e3299 Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Sun, 5 Jul 2026 10:43:41 -0400 Subject: [PATCH] Update and fix spotless issues Signed-off-by: Andriy Redko --- buildSrc/build.gradle.kts | 2 +- ...earch-java.spotless-conventions.gradle.kts | 32 ++++++++++--------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index b42d66629b..efbca7acd3 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -44,6 +44,6 @@ repositories { dependencies { implementation("org.ajoberstar.grgit:grgit-gradle:5.3.3") - implementation("com.diffplug.spotless", "spotless-plugin-gradle", "6.25.0") + implementation("com.diffplug.spotless", "spotless-plugin-gradle", "8.8.0") } diff --git a/buildSrc/src/main/kotlin/opensearch-java.spotless-conventions.gradle.kts b/buildSrc/src/main/kotlin/opensearch-java.spotless-conventions.gradle.kts index 8f03e2d995..f5f028cb2a 100644 --- a/buildSrc/src/main/kotlin/opensearch-java.spotless-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/opensearch-java.spotless-conventions.gradle.kts @@ -38,21 +38,23 @@ spotless { bumpThisNumberIfACustomStepChanges(1) val wildcardImportRegex = Regex("""^import\s+(?:static\s+)?[^*\s]+\.\*;$""", RegexOption.MULTILINE) - custom("Refuse wildcard imports") { contents -> - // Wildcard imports can't be resolved by spotless itself. - // This will require the developer themselves to adhere to best practices. - val wildcardImports = wildcardImportRegex.findAll(contents) - if (wildcardImports.any()) { - var msg = """ - Please replace the following wildcard imports with explicit imports ('spotlessApply' cannot resolve this issue): - """.trimIndent() - wildcardImports.forEach { - msg += "\n\t- ${it.value}" + custom("Refuse wildcard imports", object : java.io.Serializable, com.diffplug.spotless.FormatterFunc { + override fun apply(contents: String) : String { + // Wildcard imports can't be resolved by spotless itself. + // This will require the developer themselves to adhere to best practices. + val wildcardImports = wildcardImportRegex.findAll(contents) + if (wildcardImports.any()) { + var msg = """ + Please replace the following wildcard imports with explicit imports ('spotlessApply' cannot resolve this issue): + """.trimIndent() + wildcardImports.forEach { + msg += "\n\t- ${it.value}" + } + msg += "\n" + throw AssertionError(msg) } - msg += "\n" - throw AssertionError(msg) - } - contents - } + return contents + } + }) } } \ No newline at end of file