From 68afb082c493e6a22259312363f600ae5c337f16 Mon Sep 17 00:00:00 2001 From: Fredrik Henricsson Date: Sat, 29 Oct 2022 18:04:33 +0200 Subject: [PATCH] Add ktlint Add support for checking the code with ktlint. The ktlintCheck task can be run to get an issue report. The ktlint configuration is set up to produce a plain text report and an HTML report. This fixes #19. --- app/build.gradle | 11 +++++++++++ gradle/libs.versions.toml | 2 ++ 2 files changed, 13 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index 927868fe..0f282481 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,7 +1,10 @@ +import org.jlleitschuh.gradle.ktlint.reporter.ReporterType + plugins { alias libs.plugins.kotlin.android alias libs.plugins.kotlin.kapt alias libs.plugins.android.application + alias libs.plugins.ktlint.gradle alias libs.plugins.hilt.android alias libs.plugins.gms alias libs.plugins.spotless @@ -85,3 +88,11 @@ dependencies { task wrapper(type: Wrapper){ gradleVersion = '7.2' } + +ktlint { + android.set(true) + reporters { + reporter(ReporterType.PLAIN) + reporter(ReporterType.HTML) + } +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 36f8cd28..c37cfeaf 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -18,6 +18,7 @@ jUnitVersion = "4.13.2" kotlinVersion = "1.6.21" kotlinCoroutineAdapter = "0.9.2" kotlinCoroutinePlayServicesVersion = "1.6.4" +ktlintGradleVersion = "11.0.0" legacySupportVersion = "1.0.0" lifecycleVersion = "2.5.0" lottieVersion = "5.2.0" @@ -100,5 +101,6 @@ gms = { id = "com.google.gms.google-services", version.ref = "googleServicesVers hilt-android = { id = "com.google.dagger.hilt.android", version.ref = "hiltVersion" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlinVersion" } kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlinVersion" } +ktlint-gradle = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlintGradleVersion" } navigation-safeargs = { id = "androidx.navigation.safeargs", version.ref = "navigationVersion"} spotless = { id = "com.diffplug.spotless", version.ref = "spotlessVersion" }