Jukka Siivonen

    Jukka Siivonen

    4 years ago
    I can't find any documentation how to set up Detekt in multi module Gradle project, any tips?
    l

    Lucas

    4 years ago
    Here's an example using the Gradle Kotlin DSL. Running
    gradle detektCheck
    in the terminal the source code in
    module-a
    and
    module-b
    will be analyzed.
    build.gradle.kts
    import io.gitlab.arturbosch.detekt.extensions.DetektExtension
    
    plugins {
        id("org.jetbrains.kotlin.jvm") version "1.2.61"
        id("io.gitlab.arturbosch.detekt") version "1.0.0.RC8"
        id("java")
    }
    
    repositories {
        mavenCentral()
    }
    
    subprojects {
        apply(plugin = "org.jetbrains.kotlin.jvm")
        apply(plugin = "io.gitlab.arturbosch.detekt")
    
        repositories {
            mavenCentral()
            jcenter()
        }
    
        dependencies {
            compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
        }
    
        configure<DetektExtension> {
            defaultProfile {
                config = "${rootProject.projectDir}/detekt.yml"
                input = "$projectDir/src/main/kotlin" 
            }
        }
    }
    settings.gradle.kts
    include("module-a")
    include("module-b")
    .
    ├── build.gradle.kts
    ├── detekt.yml
    ├── module-a
    │   └── src
    │       └── main
    │           └── kotlin
    │               └── Main.kt
    ├── module-b
    │   └── src
    │       └── main
    │           └── kotlin
    │               └── Main.kt
    └── setting.gradle.kts