plugins {
    id "org.jetbrains.kotlin.jvm"
    id "io.gitlab.arturbosch.detekt"
    id 'java'
    id 'jacoco'
    id 'epilink.common-conventions'
}

repositories {
    mavenCentral()
    maven { url 'https://jitpack.io' }
    maven { url 'https://litarvan.github.io/maven' }
}

def additionalKotlinCompilerArgs = [
        "-Xopt-in=kotlin.RequiresOptIn",
        "-Xopt-in=io.ktor.locations.KtorExperimentalLocationsAPI",
        "-Werror" // All warnings as errors
]

compileKotlin {
    kotlinOptions.jvmTarget = "11"
    kotlinOptions.freeCompilerArgs += additionalKotlinCompilerArgs
}

compileTestKotlin {
    kotlinOptions.jvmTarget = "11"
    kotlinOptions.freeCompilerArgs += additionalKotlinCompilerArgs
}

dependencies {
    implementation libs.kotlin.stdlib

    testImplementation libs.bundles.kotlin.test
    testImplementation libs.junit.jupiter
    testImplementation libs.mockk

    detektPlugins libs.detekt.formatting
}

test {
    useJUnitPlatform()
}

// TODO Remove this when the default JaCoCo version is updated
jacoco {
    toolVersion = "0.8.7"
}

jacocoTestReport {
    reports {
        xml.required = true
    }
}

check.configure {
    dependsOn = dependsOn.findAll { it.name != 'detekt' }
    dependsOn += 'detektMain'
}
