From 58ab06b4f8fed73456fd219b6b0a431a92d6a41c Mon Sep 17 00:00:00 2001 From: Carlos Date: Wed, 26 Feb 2020 18:00:51 -0500 Subject: [PATCH] add ktlint (#2633) --- app/build.gradle | 5 ++ build.gradle.kts | 2 + ktlintCodeStyle.xml | 136 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 ktlintCodeStyle.xml diff --git a/app/build.gradle b/app/build.gradle index 9ec7f946d..7d0ab1cb0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,6 +5,8 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' apply plugin: 'com.github.zellius.shortcut-helper' +apply plugin: "org.jmailen.kotlinter" + shortcutHelper.filePath = './shortcuts.xml' @@ -264,6 +266,9 @@ androidExtensions { experimental = true } +preBuild.dependsOn(lintKotlin) +lintKotlin.dependsOn(formatKotlin) + if (getGradle().getStartParameter().getTaskRequests().toString().contains("Standard")) { apply plugin: 'com.google.gms.google-services' } diff --git a/build.gradle.kts b/build.gradle.kts index 8c9612171..fd707613c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,6 +11,7 @@ buildscript { dependencies { classpath("com.android.tools.build:gradle:3.6.0") classpath("com.github.zellius:android-shortcut-gradle-plugin:0.1.2") + classpath("org.jmailen.gradle:kotlinter-gradle:2.3.1") classpath("com.google.gms:google-services:4.3.3") // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -21,6 +22,7 @@ allprojects { repositories { google() maven { setUrl("https://www.jitpack.io") } + maven { setUrl("https://plugins.gradle.org/m2/") } jcenter() } } diff --git a/ktlintCodeStyle.xml b/ktlintCodeStyle.xml new file mode 100644 index 000000000..e1422c7c8 --- /dev/null +++ b/ktlintCodeStyle.xml @@ -0,0 +1,136 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
\ No newline at end of file