plugins {
    id 'java'
    id 'application'
    id 'org.javamodularity.moduleplugin' version '1.8.12'
    id 'org.openjfx.javafxplugin' version '0.0.13'
    id 'org.beryx.jlink' version '2.25.0'
}

group 'io.github.gleidsonmt'

repositories {
    mavenCentral()
}

ext {
    junitVersion = '5.10.2'
}

tasks.withType(JavaCompile).configureEach {
    options.setEncoding("utf-8")
}

application {
    mainModule = 'io.github.gleidsonmt.dashboardfx'
    mainClass = 'io.github.gleidsonmt.dashboardfx.App'
}

subprojects {
    tasks.configureEach { task ->
        if (task.name.contains("run")) {
            task.enabled = false
        }
    }
}

javafx {
//    version = '17.0.14'
    version = '23.0.2'
    modules = ['javafx.controls', 'javafx.fxml', 'javafx.web', 'javafx.swing']
}

dependencies {
    implementation files('vendor/colors-1.0.jar');
//    implementation files('vendor/cssfx-11.5.1.jar');
    implementation 'org.jetbrains:annotations:24.0.1'

    testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
    testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")

    implementation project(":blockcode")
    implementation project(":glad")
    implementation project(":presentation")
}

distTar {
    setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE)
}

distZip {
    setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE)
}

test {
    useJUnitPlatform()
}

jlink {
    imageZip = project.file("${buildDir}/distributions/app-${javafx.platform.classifier}.zip")
    options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']

    launcher {
        name = 'DashboardFx'
    }
//    forceMerge("org.scenicview")

    jpackage {

//        imageOptions = [
//                '--icon', 'logo_256.ico'
//        ]

        installerType = 'exe'
        appVersion = version
        installerOptions = [
                '--description', "A dashboardfx made in JavaFx UI Toolkit.",
                '--copyright', 'Copyright © 2025 GLEIDSON NEVES DA SILVEIRA'
//                , '--icon', 'logo_256.ico'

        ]

        addExtraDependencies("javafx")
    }

}

jlinkZip {
    group = 'distribution'
}