plugins {
    kotlin("jvm") version "2.1.10"
}

group = "be.ugent.logprog"
version = "0.1-SNAPSHOT"

repositories {
    mavenCentral()
}

dependencies {
    // CLI argument parsing
    implementation("com.xenomachina:kotlin-argparser:2.0.7")
    // Parser combinator library
    implementation("com.github.h0tk3y.betterParse:better-parse:0.4.4")

    testImplementation(kotlin("test"))
    testImplementation("org.junit.jupiter:junit-jupiter-params:5.1.0")
}

sourceSets {
    getByName("main") {
        kotlin.srcDir("src")
    }
    getByName("test") {
        kotlin.srcDir("tests")
    }
}

tasks.named<Test>("test") {
    useJUnitPlatform()
    testLogging {
        events("passed", "skipped", "failed")
    }
}

tasks.register<Jar>("fatJar") {
    manifest {
        attributes["Main-Class"] = "MainKt"
    }
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
    from(configurations.runtimeClasspath.get().map {
        if (it.isDirectory) it else zipTree(it)
    })
    with(tasks.jar.get() as CopySpec)
}

tasks {
    build {
        dependsOn("fatJar")
    }
}
