/*
 * 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-Beta5'

    // 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-Beta5"
}

repositories {
    mavenCentral()
    maven { url 'https://jitpack.io' }
}

test {
    minHeapSize = "1000m" // initial heap size
    maxHeapSize = "8000m" // maximum heap size
    jvmArgs '-XX:MaxMetaspaceSize=8000m' // mem argument for the test JVM
}

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'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0'

    // This dependency is used by the application.
    implementation 'com.google.guava:guava:33.1.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-Beta5"

    implementation 'com.github.kupietz:cistern:v1.0.4'
    implementation 'org.maltparser:maltparser:1.9.2'
    implementation 'org.apache.opennlp:opennlp-tools:2.3.2'
    implementation 'org.slf4j:slf4j-simple:2.1.0-alpha1'
    implementation 'org.apache.ant:ant:1.10.14'

}



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
}
