Add simple gradle format target

This commit is contained in:
qwerty287 2022-08-25 17:43:33 +02:00
parent 5c23e4ee52
commit 22e138a990
No known key found for this signature in database
GPG key ID: E0464C650D9D25B2

View file

@ -22,3 +22,20 @@ allprojects {
task clean(type: Delete) {
delete rootProject.buildDir
}
task format {
def proc
// first, try `intellij-idea-ultimate-edition` as command
try {
proc = 'intellij-idea-ultimate-edition format -s ".idea/codeStyles/Project.xml" -m "${PLUGIN_FILE_PATTERN:-"*"}" -r .'.execute()
} catch (ignored) {
try {
proc = 'intellij-idea-community-edition format -s ".idea/codeStyles/Project.xml" -m "${PLUGIN_FILE_PATTERN:-"*"}" -r .'.execute()
} catch (ignored2) {
println('Couldn\'t format files, IntelliJ binary is missing')
return
}
}
proc.consumeProcessOutput(System.out, System.err)
proc.waitFor()
}