瀏覽代碼

Use ktlint plugin instead of manual ktlint tasks

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 3 年之前
父節點
當前提交
eb67a31bd1
共有 3 個文件被更改,包括 4 次插入21 次删除
  1. 1 1
      .github/workflows/check.yml
  2. 2 20
      app/build.gradle
  3. 1 0
      build.gradle

+ 1 - 1
.github/workflows/check.yml

@@ -10,7 +10,7 @@ jobs:
         strategy:
             fail-fast: false
             matrix:
-                task: [ detekt, ktlint ]
+                task: [ detekt, ktlintCheck ]
         steps:
             -   uses: actions/checkout@v3
             -   name: Set up JDK 8

+ 2 - 20
app/build.gradle

@@ -31,10 +31,7 @@ apply plugin: 'kotlin-kapt'
 apply plugin: 'kotlin-android-extensions'
 apply plugin: 'com.github.spotbugs'
 apply plugin: 'io.gitlab.arturbosch.detekt'
-
-configurations {
-    ktlint
-}
+apply plugin: "org.jlleitschuh.gradle.ktlint"
 
 def urlFile = { url, fileName ->
     File file = new File("$buildDir/download/${fileName}")
@@ -149,7 +146,7 @@ android {
         }
     }
 
-    check.dependsOn 'spotbugsGplayDebugReport', 'lint', 'ktlint', 'detekt'
+    check.dependsOn 'spotbugsGplayDebug', 'lint', 'ktlintCheck', 'detekt'
     lint.dependsOn 'preBuild'
 
     compileOptions {
@@ -206,7 +203,6 @@ dependencies {
     implementation ('com.gitlab.bitfireAT:dav4jvm:2.1.3', {
         exclude group: 'org.ogce', module: 'xpp3'	// Android comes with its own XmlPullParser
     })
-    ktlint "com.pinterest:ktlint:0.44.0"
     implementation 'org.conscrypt:conscrypt-android:2.5.2'
 
     implementation 'androidx.camera:camera-core:1.0.2'
@@ -338,20 +334,6 @@ dependencies {
     gplayImplementation "com.google.firebase:firebase-messaging:23.0.0"
 }
 
-task ktlint(type: JavaExec, group: "verification") {
-    description = "Check Kotlin code style."
-    main = "com.pinterest.ktlint.Main"
-    classpath = configurations.ktlint
-    args "--reporter=plain", "--reporter=plain,output=${buildDir}/ktlint.txt,src/**/*.kt"
-}
-
-task ktlintFormat(type: JavaExec, group: "formatting") {
-    description = "Fix Kotlin code style deviations."
-    main = "com.pinterest.ktlint.Main"
-    classpath = configurations.ktlint
-    args "-F", "src/**/*.kt"
-}
-
 detekt {
     reports {
         xml {

+ 1 - 0
build.gradle

@@ -40,6 +40,7 @@ buildscript {
         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
         classpath 'gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.7.5'
         classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.19.0"
+        classpath "org.jlleitschuh.gradle:ktlint-gradle:10.2.1"
 
         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files