Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Original file line number Diff line number Diff line change
Expand Up @@ -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
}
})
}
}
Loading