[Android] Configuring ktlint for your Android project (Kotlin)

1.- app/build.gradle

android {
// …
}

configurations {
ktlint
}

2.- Add dependency and these two blocks

dependencies {
// …
ktlint “com.github.shyiko:ktlint:0.15.0”
}

task ktlint(type: JavaExec) {
main = “com.github.shyiko.ktlint.Main”
classpath = configurations.ktlint
args “src/**/*.kt”
}

check.dependsOn ktlint

task ktlintFormat(type: JavaExec) {
main = “com.github.shyiko.ktlint.Main”
classpath = configurations.ktlint
args “-F”, “src/**/*.kt”
}

Advertisements