/*
 * 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.20'

    // 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.20"
}

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.9.0'

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


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

    // 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.20"

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

}



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
}
