/*
 * Copyright (c) 2019 Adyen N.V.
 *
 * This file is open source and available under the MIT license. See the LICENSE file for more info.
 *
 * Created by ran on 23/5/2019.
 */

/**
 * This is a static code analysis for Kotlin.
 *
 * Docs: https://github.com/detekt/detekt/
 */

// cannot reference the plugins declared in the version catalogs here because it requires the use of the `plugins` block instead of the `apply plugin` command
// the `plugins` block cannot be used in gradle files such as this one, which are imported into other gradle files with the `apply from` command
apply plugin: 'io.gitlab.arturbosch.detekt'

detekt {
    toolVersion = "${libs.versions.detekt.get()}"

    input = files("src")

    config = files("$rootProject.rootDir/config/detekt/detekt.yml")
    baseline = file("$rootProject.rootDir/config/detekt/detekt-baseline.xml")
    parallel = true
    buildUponDefaultConfig = true
}

tasks.named("detekt").configure {
    reports {
        xml {
            required.set(true)
            outputLocation.set(file("${layout.buildDirectory.get().asFile}/reports/detekt/detekt-results.xml"))
        }
        html.required.set(false)
    }
}

dependencies {
    detektPlugins libs.detekt
}

tasks.detekt.jvmTarget = JavaVersion.VERSION_1_8.toString()
