plugins {
    id("application")
    id("org.fxyz3d-base")
    id("org.beryx.jlink") version "$beryxJlinkVersion"
}

ext.moduleName = "org.fxyz3d.samples"
ext.mainClassName = "org.fxyz3d.samples.Launcher"

base {
    archivesName = project.name.toLowerCase()
}

application {
    mainModule = moduleName
    mainClass = mainClassName
}

javadoc {
	enabled = false
}

dependencies {
    implementation project(":FXyz-Client")
    implementation project(":FXyz-Core")
    implementation project(":FXyz-Importers")
    implementation ("org.controlsfx:controlsfx:$controlsfxVersion") {
        exclude group:"org.openjfx"
    }
    implementation ("org.reactfx:reactfx:$reactfxVersion")
    implementation ("org.fxmisc.easybind:easybind:$easybindVersion")
    implementation ("org.jfxtras:jfxtras-controls:$jfxtrasControlsVersion")
    implementation ("org.graalvm.js:js:$graalvmJsVersion")
    implementation ("org.graalvm.js:js-scriptengine:$graalvmJsVersion")
}

javafx {
	modules = [ "javafx.controls", "javafx.fxml" ]
}

compileJava {
    doFirst {
        options.compilerArgs += [
                "--add-exports", "javafx.graphics/com.sun.javafx.scene=org.fxyz3d.samples"
        ]
    }
}

run {
    doFirst {
        jvmArgs += ["--add-exports", "javafx.base/com.sun.javafx.runtime=org.controlsfx.controls",
                    "--add-exports", "javafx.graphics/com.sun.javafx.scene=org.fxyz3d.samples"]
    }
}

jar {
    manifest {
        attributes  "Implementation-Title":    "FXyz-Samples",
                    "Implementation-Version":   project.version,
                    "Class-Path":               configurations.runtimeClasspath.collect { it.getName() }.join(" "),
                    "Main-Class":               mainClassName,
                    "Automatic-Module-Name" :   moduleName
    }
    from sourceSets.main.allJava
}

jlink {
    imageName = "FXyz"
    options = ["--strip-debug", "--compress", "2", "--no-header-files", "--no-man-pages"]
    addExtraDependencies("javafx")
    launcher {
        name = "FXyzSamples"
        jvmArgs = ["--add-exports", "javafx.base/com.sun.javafx.runtime=org.fxyz3d.merged.module",
                   "--add-exports", "javafx.graphics/com.sun.javafx.scene=org.fxyz3d.FXyz.Samples"]
    }
}
