Skip to content

Commit b3b7a95

Browse files
committed
Prepare version bump of spotless
spotless v7 fails on Gradle with some `SerializationException`, moving the `callable` works around this issue (as [mentioned here](diffplug/spotless#2387)). Also removing the unnecessary `buildscript.dependencies` and the implied 2nd spotless version definition.
1 parent ba9eff5 commit b3b7a95

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

build-logic/src/main/kotlin/polaris-java.gradle.kts

+14-8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
* under the License.
1818
*/
1919

20+
import com.diffplug.spotless.FormatterFunc
21+
import java.io.Serializable
2022
import net.ltgt.gradle.errorprone.errorprone
2123
import org.gradle.api.tasks.compile.JavaCompile
2224
import org.gradle.api.tasks.testing.Test
@@ -80,19 +82,23 @@ tasks.withType(Jar::class).configureEach {
8082
}
8183

8284
spotless {
83-
val disallowWildcardImports = { text: String ->
84-
val regex = "~/import .*\\.\\*;/".toRegex()
85-
if (regex.matches(text)) {
86-
throw GradleException("Wildcard imports disallowed - ${regex.findAll(text)}")
87-
}
88-
text
89-
}
9085
java {
9186
target("src/main/java/**/*.java", "src/testFixtures/java/**/*.java", "src/test/java/**/*.java")
9287
googleJavaFormat()
9388
licenseHeaderFile(rootProject.file("codestyle/copyright-header-java.txt"))
9489
endWithNewline()
95-
custom("disallowWildcardImports", disallowWildcardImports)
90+
custom(
91+
"disallowWildcardImports",
92+
object : Serializable, FormatterFunc {
93+
override fun apply(text: String): String {
94+
val regex = "~/import .*\\.\\*;/".toRegex()
95+
if (regex.matches(text)) {
96+
throw GradleException("Wildcard imports disallowed - ${regex.findAll(text)}")
97+
}
98+
return text
99+
}
100+
},
101+
)
96102
toggleOffOn()
97103
}
98104
kotlinGradle {

build.gradle.kts

+1-6
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@
2020
import java.net.URI
2121
import org.nosphere.apache.rat.RatTask
2222

23-
buildscript {
24-
repositories { maven { url = java.net.URI("https://plugins.gradle.org/m2/") } }
25-
dependencies {
26-
classpath("com.diffplug.spotless:spotless-plugin-gradle:${libs.plugins.spotless.get().version}")
27-
}
28-
}
23+
buildscript { repositories { maven { url = java.net.URI("https://plugins.gradle.org/m2/") } } }
2924

3025
plugins {
3126
id("idea")

gradle/libs.versions.toml

-1
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,3 @@ threeten-extra = { module = "org.threeten:threeten-extra", version = "1.8.0" }
8080
[plugins]
8181
openapi-generator = { id = "org.openapi.generator", version = "7.10.0" }
8282
rat = { id = "org.nosphere.apache.rat", version = "0.8.1" }
83-
spotless = { id = "com.diffplug.spotless", version = "6.25.0" }

0 commit comments

Comments
 (0)