From 8b59b003fbfe6b062bb6fd39f2569175f8e9275d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebastian=20K=C3=BCrten?= <sebastian@mobanisto.de>
Date: Thu, 14 Apr 2022 15:56:11 +0200
Subject: [PATCH] Properly configure checkstyle for Android modules

---
 dont-kill-me-lib/build.gradle |  3 +++
 gradle/checkstyle.gradle      | 29 +++++++++++++++++++++++++++++
 mailbox-android/build.gradle  |  1 +
 3 files changed, 33 insertions(+)
 create mode 100644 gradle/checkstyle.gradle

diff --git a/dont-kill-me-lib/build.gradle b/dont-kill-me-lib/build.gradle
index 8e3efb0b..58d6d857 100644
--- a/dont-kill-me-lib/build.gradle
+++ b/dont-kill-me-lib/build.gradle
@@ -1,5 +1,6 @@
 plugins {
     id 'com.android.library'
+    id 'checkstyle' // only needed for Java code
 }
 
 android {
@@ -27,3 +28,5 @@ android {
 dependencies {
     implementation "androidx.annotation:annotation:1.3.0"
 }
+
+apply from: "${rootProject.rootDir}/gradle/checkstyle.gradle"
diff --git a/gradle/checkstyle.gradle b/gradle/checkstyle.gradle
new file mode 100644
index 00000000..a280dc68
--- /dev/null
+++ b/gradle/checkstyle.gradle
@@ -0,0 +1,29 @@
+task checkstyleMain(type: Checkstyle) {
+    source 'src/main/java'
+    include '**/*.java'
+    classpath = files()
+    reports {
+        xml {
+            destination file("build/reports/checkstyle/main.xml")
+        }
+        html {
+            destination file("build/reports/checkstyle/main.html")
+        }
+    }
+    check.dependsOn it
+}
+
+task checkstyleTest(type: Checkstyle) {
+    source 'src/test/java'
+    include '**/*.java'
+    classpath = files()
+    reports {
+        xml {
+            destination file("build/reports/checkstyle/test.xml")
+        }
+        html {
+            destination file("build/reports/checkstyle/test.html")
+        }
+    }
+    check.dependsOn it
+}
diff --git a/mailbox-android/build.gradle b/mailbox-android/build.gradle
index b692d539..66bd53bb 100644
--- a/mailbox-android/build.gradle
+++ b/mailbox-android/build.gradle
@@ -152,3 +152,4 @@ tasks.withType(MergeResources) {
 }
 
 apply from: "${rootProject.rootDir}/gradle/ktlint.gradle"
+apply from: "${rootProject.rootDir}/gradle/checkstyle.gradle"
-- 
GitLab