/*
 * This file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Kotlin application project to get you started.
 * For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle
 * User Manual available at https://docs.gradle.org/7.4.2/userguide/building_java_projects.html
 */


plugins {
    // Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin.
    id 'org.jetbrains.kotlin.jvm' version '2.0.0-Beta4'

    // Apply the application plugin to add support for building a CLI application in Java.
    id 'application'
    id 'com.github.johnrengelman.shadow' version '8.1.1'
    id ("org.jetbrains.kotlin.kapt") version "2.0.0-Beta4"
}


repositories {
    // Use Maven Central for resolving dependencies.
    mavenCentral()
}

dependencies {
    // Align versions of all Kotlin components
    implementation platform('org.jetbrains.kotlin:kotlin-bom')

    // Use the Kotlin JDK 8 standard library.
    implementation 'org.jetbrains.kotlin:kotlin-stdlib'

    // This dependency is used by the application.
    implementation 'com.google.guava:guava:33.0.0-jre'


    kapt("info.picocli:picocli-codegen:4.7.5")
    implementation ("info.picocli:picocli:4.7.5")

    // Use the Kotlin test library.
    testImplementation 'org.jetbrains.kotlin:kotlin-test'

    // Use the Kotlin JUnit integration.
    testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
    testImplementation "org.jetbrains.kotlin:kotlin-test:2.0.0-Beta4"
}


application {
    // Define the main class for the application.
    mainClass = 'de.ids_mannheim.korapxmltools.KorapXml2ConlluKt'
}

jar {
    // Will include every single one of your dependencies, project or not
    // def lowerCasedName = baseName.toLowerCase()
    // def normalizedName = lowerCasedName.substring(0,1).toUpperCase() + lowerCasedName.substring(1)

    manifest.attributes(
            'Class-Path': configurations.compileClasspath.collect { it.getName() }.join(' '),
            'Main-Class': "de.ids_mannheim.korapxmltools.KorapXml2ConlluKt"
    )
    shadowJar {
        archiveBaseName.set('korapxml2conllu')
        archiveClassifier.set('')
        archiveVersion.set('')
    }
}


configurations {
    runtimeLib.extendsFrom implementation
}
