plugins {
    alias(libs.plugins.kotlin.jvm)
    alias(libs.plugins.detekt)
    `maven-publish`
}

group = "com.marvinelsen"
version = "1.0.0"

repositories {
    mavenCentral()
    maven {
        url = uri("https://gitea.marvinelsen.com/api/packages/marvinelsen/maven")
    }
}

dependencies {
    detektPlugins(libs.detekt.formatting)

    testImplementation(libs.kotest.core)
    testImplementation(libs.kotest.assertions)
}

tasks.test {
    useJUnitPlatform()
}

kotlin {
    jvmToolchain(21)
}

publishing {
    publications {
        create<MavenPublication>("maven") {
            groupId = project.group as String
            artifactId = "tatoeba-parser"
            version = project.version as String

            from(components["java"])
        }
    }
    repositories {
        maven {
            name = "Gitea"
            url = uri("https://gitea.marvinelsen.com/api/packages/marvinelsen/maven")
            credentials(HttpHeaderCredentials::class) {
                name = "Authorization"
                value = "token ${System.getenv("GITEA_TOKEN")}"
            }
            isAllowInsecureProtocol = true
            authentication {
                val header by registering(HttpHeaderAuthentication::class)
            }
        }
    }
}

detekt {
    buildUponDefaultConfig = true
    allRules = false
    autoCorrect = true
}
