[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”
}

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s