import dev.detekt.gradle.extensions.FailOnSeverity

plugins {
    base
    alias(libs.plugins.detekt)
    alias(libs.plugins.kover)
    alias(libs.plugins.nexusPublish) // https://github.com/gradle-nexus/publish-plugin
    alias(libs.plugins.openrewrite)
    kotlin("plugin.serialization") version libs.versions.kotlin apply false
    `dokka-convention`
    signing
}

allprojects {
    repositories {
        mavenCentral()
        mavenLocal()
    }
}

// Common configuration for subprojects
subprojects {
    apply(plugin = "org.jetbrains.dokka")
    apply(plugin = "dev.detekt")

    detekt {
        config.from(rootProject.file("detekt.yml"))
        buildUponDefaultConfig = true
        parallel = true
        debug = false
        failOnSeverity = FailOnSeverity.Warning
    }
}

dependencies {
    kover(project(":a2a-client"))
    kover(project(":test-utils"))
    kover(project(":ai-mocks-a2a"))
    kover(project(":ai-mocks-a2a-models"))
    kover(project(":ai-mocks-anthropic"))
    kover(project(":ai-mocks-core"))
    kover(project(":ai-mocks-gemini"))
    kover(project(":ai-mocks-ollama"))
    kover(project(":ai-mocks-openai"))
}

kover {
    reports {
        filters {
            includes {
                classes("dev.mokksy.*")
            }
            excludes {
                classes("**.*StressTest*")
            }
        }

        total {
            xml
            html
        }

        verify {
            rule {
                bound {
                    minValue = 70
                }
            }
        }
    }
}

rewrite {
    activeRecipe(
//        "org.openrewrite.kotlin.format.AutoFormat",
        "org.openrewrite.gradle.RemoveRedundantDependencyVersions",
        "org.openrewrite.kotlin.cleanup.RemoveLambdaArgumentParentheses",
        "org.openrewrite.kotlin.cleanup.UnnecessaryTypeParentheses",
    )
    isExportDatatables = true
}
