Skip to content

Commit

Permalink
add sample
Browse files Browse the repository at this point in the history
  • Loading branch information
eadm committed Jan 19, 2020
1 parent 8efe987 commit d607d80
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply from: '../ktlint.gradle'

android {
compileSdkVersion versions.compileSdk
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/ru/nobird/android/ktlint/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}

fun explicitPublicTypeViolation() = "explicit public type violation"
}
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ allprojects {
google()
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://dl.bintray.com/eadm/ru.nobird.android" }
}
}

Expand Down
4 changes: 3 additions & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ext.versions = [
junit : '4.12',

ktlint : '0.34.2',
ktlintRules : '1.0'
]

ext.gradlePlugins = [
Expand All @@ -38,5 +39,6 @@ ext.libraries = [

junit : "junit:junit:$versions.junit",

ktlint : "com.pinterest:ktlint:$versions.ktlint"
ktlint : "com.pinterest:ktlint:$versions.ktlint",
ktlintRules : "ru.nobird.android.ktlint:rules:$versions.ktlintRules"
]
33 changes: 33 additions & 0 deletions ktlint.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
repositories {
jcenter()
}

configurations {
ktlint
}

dependencies {
ktlint libraries.ktlint
ktlint libraries.ktlintRules
// additional 3rd party ruleset(s) can be specified here
// just add them to the classpath (ktlint 'groupId:artifactId:version') and
// ktlint will pick them up
}

task ktlint(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
main = "com.pinterest.ktlint.Main"
classpath = configurations.ktlint
args = ["--disabled_rules=no-multi-spaces,package-name,final-newline,import-ordering", "src/main/java/**/*.kt"]
}
check.dependsOn ktlint

task ktlintFormat(type: JavaExec, group: "verification") {
description = "Format Kotlin code style."
main = "com.pinterest.ktlint.Main"
classpath = configurations.ktlint
args = ["-F", "--disabled_rules=no-multi-spaces,package-name,final-newline,import-ordering", "src/main/java/**/*.kt"]
// to generate report in checkstyle format prepend following args:
// "--reporter=plain", "--reporter=checkstyle,output=${buildDir}/ktlint.xml"
// see https://github.com/shyiko/ktlint#usage for more
}

0 comments on commit d607d80

Please sign in to comment.