diff --git a/.scripts/ktlint.gradle b/.scripts/ktlint.gradle index 09b2416..f580d5b 100644 --- a/.scripts/ktlint.gradle +++ b/.scripts/ktlint.gradle @@ -6,8 +6,8 @@ dependencies { ktlint "com.pinterest:ktlint:0.45.2" } -task ktlint(type: JavaExec) { - main = "com.pinterest.ktlint.Main" +tasks.register('ktlintFormat', JavaExec) { + mainClass = "com.pinterest.ktlint.Main" classpath = configurations.ktlint args("$rootDir/**/*.kt", "!$rootDir/**/build/**") jvmArgs "--add-opens=java.base/java.lang=ALL-UNNAMED" @@ -18,4 +18,14 @@ task ktlint(type: JavaExec) { logger.quiet("(KTLINT): auto correction is enabled") args "-F" } -} \ No newline at end of file +} + +tasks.register('ktlintCheck', JavaExec) { + classpath = configurations.ktlint + mainClass = "com.pinterest.ktlint.Main" + args "src/**/*.kt", "**.kts", "!**/build/**" +} + +tasks.preBuild.dependsOn ktlintFormat + +tasks.ktlintFormat.dependsOn ktlintCheck \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index b0d25b7..0970d8a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,7 +5,7 @@ plugins { id 'org.jetbrains.kotlin.plugin.serialization' version '1.8.21' } -// apply from: "$project.rootDir/.scripts/ktlint.gradle" +apply from: "$project.rootDir/.scripts/ktlint.gradle" android { compileSdk 33 diff --git a/build.gradle b/build.gradle index 512b134..587c186 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,6 @@ plugins { id 'com.android.application' version '8.0.0' apply false id 'com.android.library' version '8.0.0' apply false id 'org.jetbrains.kotlin.android' version '1.7.10' apply false - id "org.jlleitschuh.gradle.ktlint" version "12.1.0" } task clean(type: Delete) {