Skip to content

Commit

Permalink
Prepare version bump of spotless
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
snazy committed Jan 10, 2025
1 parent ba9eff5 commit b3b7a95
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
22 changes: 14 additions & 8 deletions build-logic/src/main/kotlin/polaris-java.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 1 addition & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 0 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }

0 comments on commit b3b7a95

Please sign in to comment.