plugins {
    id "groovy"
    id "com.github.johnrengelman.shadow" version "5.2.0"
    id "application"
    id 'com.google.cloud.tools.jib' version '3.4.5'
}

version "0.1"
group 'example.micronaut-jib'

repositories {
    mavenCentral()
}

configurations {
    // for dependencies that are needed for development only
    developmentOnly
}

dependencies {
    compileOnly(enforcedPlatform("io.micronaut:micronaut-bom:$micronautVersion"))
    compileOnly("io.micronaut:micronaut-inject-groovy")
    implementation(enforcedPlatform("io.micronaut:micronaut-bom:$micronautVersion"))
    implementation("io.micronaut:micronaut-inject")
    implementation("io.micronaut:micronaut-validation")
    implementation("io.micronaut:micronaut-runtime-groovy")
    implementation("javax.annotation:javax.annotation-api")
    implementation("io.micronaut:micronaut-http-server-netty")
    implementation("io.micronaut:micronaut-http-client")
    runtimeOnly("ch.qos.logback:logback-classic:1.2.3")
    testImplementation enforcedPlatform("io.micronaut:micronaut-bom:$micronautVersion")
    testImplementation("io.micronaut:micronaut-inject-groovy")
    testImplementation("org.spockframework:spock-core") {
        exclude group: "org.codehaus.groovy", module: "groovy-all"
    }
    testImplementation("io.micronaut.test:micronaut-test-spock")
}

test.classpath += configurations.developmentOnly

mainClassName = "example.micronaut.Application"

tasks.withType(GroovyCompile) {
    groovyOptions.forkOptions.jvmArgs.add('-Dgroovy.parameters=true')
}

shadowJar {
    mergeServiceFiles()
}

tasks.withType(JavaExec) {
    classpath += configurations.developmentOnly
    jvmArgs('-XX:TieredStopAtLevel=1', '-Dcom.sun.management.jmxremote')
}
