From 70a08fb58b403fecb68a0a8194190d42e4341e30 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebastian=20K=C3=BCrten?= <sebastian@mobanisto.de>
Date: Mon, 15 May 2023 15:18:41 +0200
Subject: [PATCH] Add checkstyle plugin and configuration

---
 config/checkstyle/checkstyle.xml  | 19 +++++++++++++++++++
 onionwrapper-android/build.gradle |  5 +++++
 onionwrapper-core/build.gradle    |  5 +++++
 onionwrapper-java/build.gradle    |  5 +++++
 4 files changed, 34 insertions(+)
 create mode 100644 config/checkstyle/checkstyle.xml

diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
new file mode 100644
index 0000000..1e63e0e
--- /dev/null
+++ b/config/checkstyle/checkstyle.xml
@@ -0,0 +1,19 @@
+<!DOCTYPE module PUBLIC
+          "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
+          "https://checkstyle.org/dtds/configuration_1_3.dtd">
+<module name="Checker">
+  <property name="tabWidth" value="4"/>
+  <property name="charset" value="UTF-8"/>
+  <module name="LineLength">
+    <property name="fileExtensions" value="java"/>
+    <property name="max" value="100"/>
+    <property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
+  </module>
+  <module name="TreeWalker">
+    <module name="RegexpSinglelineJava">
+      <property name="format" value="^\t* +\t*\S"/>
+      <property name="message" value="Line has leading space characters; indentation should be performed with tabs only."/>
+      <property name="ignoreComments" value="true"/>
+    </module>
+  </module>
+</module>
diff --git a/onionwrapper-android/build.gradle b/onionwrapper-android/build.gradle
index d1dd271..8b531a8 100644
--- a/onionwrapper-android/build.gradle
+++ b/onionwrapper-android/build.gradle
@@ -1,6 +1,7 @@
 plugins {
     id 'com.android.library'
     id 'com.vanniktech.maven.publish' version '0.18.0'
+    id 'checkstyle'
 }
 
 android {
@@ -27,6 +28,10 @@ android {
     }
 }
 
+checkstyle {
+    configFile = new File('../config/checkstyle/checkstyle.xml')
+}
+
 dependencies {
     api project(':onionwrapper-core')
     api 'org.briarproject:dont-kill-me-lib:0.2.7'
diff --git a/onionwrapper-core/build.gradle b/onionwrapper-core/build.gradle
index 7167ad5..2886fe4 100644
--- a/onionwrapper-core/build.gradle
+++ b/onionwrapper-core/build.gradle
@@ -1,6 +1,7 @@
 plugins {
     id 'java-library'
     id 'com.vanniktech.maven.publish' version '0.18.0'
+    id 'checkstyle'
 }
 
 java {
@@ -8,6 +9,10 @@ java {
     targetCompatibility = JavaVersion.VERSION_1_8
 }
 
+checkstyle {
+    configFile = new File('../config/checkstyle/checkstyle.xml')
+}
+
 dependencies {
     api 'org.briarproject:null-safety:0.1'
     api 'com.google.code.findbugs:jsr305:3.0.2'
diff --git a/onionwrapper-java/build.gradle b/onionwrapper-java/build.gradle
index 1f043fa..913f000 100644
--- a/onionwrapper-java/build.gradle
+++ b/onionwrapper-java/build.gradle
@@ -5,6 +5,7 @@ import static org.briarproject.onionwrapper.OsUtils.currentOS
 plugins {
     id 'java-library'
     id 'com.vanniktech.maven.publish' version '0.18.0'
+    id 'checkstyle'
 }
 
 java {
@@ -12,6 +13,10 @@ java {
     targetCompatibility = JavaVersion.VERSION_1_8
 }
 
+checkstyle {
+    configFile = new File('../config/checkstyle/checkstyle.xml')
+}
+
 dependencies {
     api project(':onionwrapper-core')
     def jna_version = '4.5.2'
-- 
GitLab