Skip to content

Commit

Permalink
Remove ktlint gradle plugin and add ktlintCheck to ktlint.gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
shubertm authored and kirillt committed Jan 22, 2024
1 parent b8df169 commit fa814c4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
16 changes: 13 additions & 3 deletions .scripts/ktlint.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -18,4 +18,14 @@ task ktlint(type: JavaExec) {
logger.quiet("(KTLINT): auto correction is enabled")
args "-F"
}
}
}

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
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit fa814c4

Please sign in to comment.