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

group = "com.marvinelsen"
version = "1.0.1"

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

dependencies {
    detektPlugins(libs.detekt.formatting)

    implementation(libs.chinese.transliteration)
    implementation(libs.kotlinx.serialization.json)

    implementation(libs.apache.commons.csv)

    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 = "cross-straits-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
}
