plugins {
    id "java"
    id "groovy"
    id "io.micronaut.application" version "4.5.3"
    id "com.github.ben-manes.versions" version "0.52.0"
}

group "org.exacaster.lighter"
version "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

java {
    sourceCompatibility = JavaVersion.VERSION_17
}

micronaut {
    version = "4.8.2"
    runtime "netty"
}
mainClassName = "com.exacaster.lighter.Application"

def sparkVersion = project.hasProperty("SPARK_VERSION") ? project.getProperty("SPARK_VERSION") : "3.5.6"
def hadoopVersion = "3.4.1"
def k8sClientVersion = "7.3.1"
def shedlockVersion = "6.8.0"

dependencies {
    annotationProcessor "io.micronaut.openapi:micronaut-openapi"
    annotationProcessor "io.micronaut.validation:micronaut-validation-processor"
    annotationProcessor "io.micronaut.data:micronaut-data-processor"

    implementation "io.micronaut.validation:micronaut-validation"

    implementation "io.micronaut.flyway:micronaut-flyway"
    implementation "io.swagger.core.v3:swagger-annotations"

    implementation "io.micronaut.sql:micronaut-jdbc-hikari"
    implementation "io.micronaut.sql:micronaut-jdbi"
    implementation "io.micronaut.data:micronaut-data-jdbc"

    implementation "io.micronaut:micronaut-http-client"
    implementation "io.micronaut:micronaut-jackson-databind"

    implementation "org.apache.spark:spark-launcher_2.13:${sparkVersion}"
    implementation "io.fabric8:kubernetes-client:${k8sClientVersion}"
    implementation("org.apache.hadoop:hadoop-yarn-client:${hadoopVersion}") {
        exclude(group: "ch.qos.reload4j", module: "reload4j")
        exclude(group: "org.slf4j", module: "slf4j-reload4j")
    }
    implementation("org.apache.hadoop:hadoop-common:${hadoopVersion}") {
        exclude(group: "ch.qos.reload4j", module: "reload4j")
        exclude(group: "org.slf4j", module: "slf4j-reload4j")
    }
    implementation "net.sf.py4j:py4j:0.10.9.9"

    implementation "net.javacrumbs.shedlock:shedlock-micronaut4:${shedlockVersion}"
    implementation "net.javacrumbs.shedlock:shedlock-provider-jdbc-template:${shedlockVersion}"

    runtimeOnly "io.micronaut.micrometer:micronaut-micrometer-core"
    runtimeOnly "io.micronaut.micrometer:micronaut-micrometer-registry-prometheus"
    runtimeOnly "io.micronaut:micronaut-management"

    runtimeOnly "org.yaml:snakeyaml"
    runtimeOnly "com.h2database:h2"
    runtimeOnly "org.postgresql:postgresql"
    runtimeOnly "org.flywaydb:flyway-database-postgresql"

    testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.12.2"
    testRuntimeOnly "net.bytebuddy:byte-buddy:1.17.5"
    testRuntimeOnly "org.objenesis:objenesis:3.4"

    testImplementation "io.micronaut:micronaut-inject-groovy"
    testImplementation "io.micronaut.test:micronaut-test-spock"
    testImplementation "io.micronaut:micronaut-http-client"
    testImplementation "io.fabric8:kubernetes-server-mock:${k8sClientVersion}"
}

tasks.withType(JavaCompile) {
    options.fork = true
    options.forkOptions.jvmArgs << '-Dmicronaut.openapi.views.spec=swagger-ui.enabled=true,swagger-ui.theme=flattop'
}

test {
    useJUnitPlatform()
}
