Skip to content

Commit

Permalink
Allow overriding eclipse formatter config file
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia committed Sep 4, 2024
1 parent 4d41ff3 commit d011749
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ plugins {
id("com.diffplug.spotless")
}

interface SpotlessConventionsPluginExtension {
val eclipseFormatterConfigFile: RegularFileProperty
}

val extension = project.extensions.create<SpotlessConventionsPluginExtension>("spotlessConventions")

extension.eclipseFormatterConfigFile.convention(rootProject.layout.projectDirectory.file("buildSrc/formatterConfig.xml"))

spotless {
java {
target("**/*.java")
Expand All @@ -20,11 +28,15 @@ spotless {
importOrder()
removeUnusedImports()

eclipse().configFile(rootProject.file("buildSrc/formatterConfig.xml"))
eclipse().configFile(extension.eclipseFormatterConfigFile)

trimTrailingWhitespace()
endWithNewline()

// NOTE: Any time a custom step below is modified, bump this number.
// Allows up-to-date checks to work correctly with custom steps.
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.
Expand Down
4 changes: 4 additions & 0 deletions java-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,8 @@ tasks.withType<Jar> {
"checksum"("algorithm" to "sha-512", "file" to archiveFile.get(), "fileext" to ".sha512")
}
}
}

spotlessConventions {
eclipseFormatterConfigFile = rootProject.file("buildSrc/formatterConfig-generated.xml")
}

0 comments on commit d011749

Please sign in to comment.