// SPDX-FileCopyrightText: 2021 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0

plugins {
    id 'application'
    id 'org.graalvm.buildtools.native' version '0.10.6'
    id 'com.gradleup.shadow' version '8.3.6'
}

graalvmNative {
    toolchainDetection = true
}

dependencies {

    testImplementation(project(":pgpainless-core"))

    testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
    testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"

    // implementation "ch.qos.logback:logback-core:1.2.6"
    // We want logback logging in tests and in the app
    testImplementation "ch.qos.logback:logback-classic:$logbackVersion"
    // implementation "ch.qos.logback:logback-classic:$logbackVersion"
    implementation "org.slf4j:slf4j-nop:$slf4jVersion"

    implementation(project(":pgpainless-sop"))
    implementation "org.pgpainless:sop-java-picocli:$sopJavaVersion"

    // https://mvnrepository.com/artifact/com.google.code.findbugs/jsr305
    implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
}

mainClassName = 'org.pgpainless.cli.PGPainlessCLI'

application {
    mainClass = mainClassName
}

run {
    // https://stackoverflow.com/questions/59445306/pipe-into-gradle-run
    standardInput = System.in
    // https://discuss.gradle.org/t/how-can-i-provide-command-line-args-to-application-started-with-gradle-run/6474/5
    if (project.hasProperty("appArgs")) {
        args Eval.me(appArgs)
    }
}
