Moves to spotless

This commit is contained in:
Vitor Pamplona
2024-01-06 10:44:05 -05:00
parent ed6c1e62e4
commit de61f7f383
9 changed files with 60 additions and 16 deletions

View File

@@ -26,16 +26,9 @@ plugins {
id 'org.jetbrains.kotlin.jvm' version '1.9.10' apply false
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.10' apply false
id 'androidx.benchmark' version '1.1.1' apply false
id 'com.diffplug.spotless' version '6.22.0' apply false
}
tasks.register('installGitHook', Copy) {
from new File(rootProject.rootDir, 'git-hooks/pre-commit')
from new File(rootProject.rootDir, 'git-hooks/pre-push')
into { new File(rootProject.rootDir, '.git/hooks') }
fileMode 0777
}
tasks.getByPath(':app:preBuild').dependsOn installGitHook
subprojects {
tasks.withType(KotlinCompile).configureEach {
kotlinOptions {
@@ -55,4 +48,35 @@ subprojects {
}
}
}
}
apply plugin: 'com.diffplug.spotless'
spotless {
kotlin {
target '**/*.kt'
targetExclude("$buildDir/**/*.kt")
ktlint("1.1.0")
ktfmt().googleStyle()
licenseHeaderFile rootProject.file('spotless/copyright.txt'), "package|import|class|object|sealed|open|interface|abstract "
}
groovyGradle {
target '*.gradle'
}
afterEvaluate {
tasks.named("preBuild") {
dependsOn("spotlessApply")
}
}
}
}
tasks.register('installGitHook', Copy) {
from new File(rootProject.rootDir, 'git-hooks/pre-commit')
from new File(rootProject.rootDir, 'git-hooks/pre-push')
into { new File(rootProject.rootDir, '.git/hooks') }
fileMode 0777
}
tasks.getByPath(':app:preBuild').dependsOn installGitHook