diff --git a/build-logic/src/main/kotlin/polaris-java.gradle.kts b/build-logic/src/main/kotlin/polaris-java.gradle.kts index 5226fbdde..16fc36cc5 100644 --- a/build-logic/src/main/kotlin/polaris-java.gradle.kts +++ b/build-logic/src/main/kotlin/polaris-java.gradle.kts @@ -17,6 +17,8 @@ * under the License. */ +import com.diffplug.spotless.FormatterFunc +import java.io.Serializable import net.ltgt.gradle.errorprone.errorprone import org.gradle.api.tasks.compile.JavaCompile import org.gradle.api.tasks.testing.Test @@ -80,19 +82,23 @@ tasks.withType(Jar::class).configureEach { } spotless { - val disallowWildcardImports = { text: String -> - val regex = "~/import .*\\.\\*;/".toRegex() - if (regex.matches(text)) { - throw GradleException("Wildcard imports disallowed - ${regex.findAll(text)}") - } - text - } java { target("src/main/java/**/*.java", "src/testFixtures/java/**/*.java", "src/test/java/**/*.java") googleJavaFormat() licenseHeaderFile(rootProject.file("codestyle/copyright-header-java.txt")) endWithNewline() - custom("disallowWildcardImports", disallowWildcardImports) + custom( + "disallowWildcardImports", + object : Serializable, FormatterFunc { + override fun apply(text: String): String { + val regex = "~/import .*\\.\\*;/".toRegex() + if (regex.matches(text)) { + throw GradleException("Wildcard imports disallowed - ${regex.findAll(text)}") + } + return text + } + }, + ) toggleOffOn() } kotlinGradle { diff --git a/build.gradle.kts b/build.gradle.kts index 4ba465e7b..a2a44525e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,12 +20,7 @@ import java.net.URI import org.nosphere.apache.rat.RatTask -buildscript { - repositories { maven { url = java.net.URI("https://plugins.gradle.org/m2/") } } - dependencies { - classpath("com.diffplug.spotless:spotless-plugin-gradle:${libs.plugins.spotless.get().version}") - } -} +buildscript { repositories { maven { url = java.net.URI("https://plugins.gradle.org/m2/") } } } plugins { id("idea") diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7abce416e..7ca364aa0 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -80,4 +80,3 @@ threeten-extra = { module = "org.threeten:threeten-extra", version = "1.8.0" } [plugins] openapi-generator = { id = "org.openapi.generator", version = "7.10.0" } rat = { id = "org.nosphere.apache.rat", version = "0.8.1" } -spotless = { id = "com.diffplug.spotless", version = "6.25.0" }