From 59c85515ebae80de6ae3bf9cc3f74a3b4deaff4b Mon Sep 17 00:00:00 2001 From: Kevin Brightwell Date: Sun, 23 Apr 2023 12:39:43 -0400 Subject: [PATCH] [Kotlin] Add Kotlin source support to build chain (#37) This adds unidirectional Kotlin support for writing code in Kotlin and using it in Groovy. Extracted from #29 --- build.gradle.kts | 23 +++++++++++++++++++++++ config/detekt-config.yml | 20 ++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 config/detekt-config.yml diff --git a/build.gradle.kts b/build.gradle.kts index d70cd9d..5bd89a4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,6 +3,8 @@ import com.gradle.publish.PublishTask.GRADLE_PUBLISH_SECRET plugins { id("groovy") + id("org.jetbrains.kotlin.jvm") version "1.8.20" + id("io.gitlab.arturbosch.detekt") version "1.22.0" id("com.gradle.plugin-publish") version "1.2.0" id("java-gradle-plugin") } @@ -68,3 +70,24 @@ dependencies { testImplementation("junit:junit:4.13.2") } +tasks.compileGroovy { + classpath += files(tasks.compileKotlin.flatMap { it.destinationDirectory }) +} + +tasks.classes { + dependsOn(tasks.compileGroovy) +} + +detekt { + parallel = true + autoCorrect = true + + buildUponDefaultConfig = true // preconfigure defaults + config = files("$rootDir/config/detekt-config.yml") + + allRules = false // activate all available (even unstable) rules. +} + +dependencies { + detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.22.0") +} \ No newline at end of file diff --git a/config/detekt-config.yml b/config/detekt-config.yml new file mode 100644 index 0000000..88ea450 --- /dev/null +++ b/config/detekt-config.yml @@ -0,0 +1,20 @@ +formatting: + active: true + Indentation: + active: true + indentSize: 2 + PackageName: + active: false + +style: + active: true + ReturnCount: + max: 4 + +complexity: + LongMethod: + excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] + +naming: + PackageNaming: + packagePattern: '[a-z]+(\.[a-z][A-Za-z0-9_]*)*' \ No newline at end of file