Spotless code autoformatting

This commit is contained in:
AnimeGitB
2022-07-09 14:20:25 +09:30
parent f1b63c56b1
commit 425590156c
3 changed files with 77 additions and 3 deletions

View File

@@ -34,6 +34,9 @@ plugins {
// Maven
id 'maven-publish'
id 'signing'
// Spotless formatter
id "com.diffplug.spotless" version "6.8.0"
}
compileJava.options.encoding = "UTF-8"
@@ -93,8 +96,8 @@ dependencies {
compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24'
testCompileOnly 'org.projectlombok:lombok:1.18.24'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.24'
testCompileOnly 'org.projectlombok:lombok:1.18.24'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.24'
}
configurations.all {
@@ -238,6 +241,30 @@ eclipse {
}
}
spotless {
// optional: limit format enforcement to just the files changed by this feature branch
ratchetFrom 'LintRatchet'
format 'misc', {
// define the files to apply `misc` to
target '*.gradle', '*.md', '.gitignore'
// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces() // or spaces. Takes an integer argument if you don't like 4
endWithNewline()
}
java {
// don't need to set target, it is inferred from java
// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces() // or spaces. Takes an integer argument if you don't like 4
endWithNewline()
replaceRegex('Force one space between if/etc. and ( or {', '(?<=\\b(?:if|for|while|switch|try|else|catch|finally|synchronized)) *(?=[\\(\\{])', ' ')
replaceRegex('Force one space between ) and {', '\\) *\\{(?!\\})', ') {')
}
}
signing {
if(!version.endsWith('-dev')) {
sign publishing.publications.mavenJava