構建Java模塊運行時圖像對其他操作系統

我重寫我的小Java 8項目從簡單的jar到單個模塊在Java 11。 在過去我和Gradle構建jar兼容Windows和Linux。 現在我配置Gradle構建模塊和創建自定義運行時圖像,但只有在Linux上工作。 我的自定義運行時圖像僅包含Linux庫。 有可能在Linux上構建圖像爲Windows ? 我知道我可以打開我的項目在Windows和創建圖像但我想保持我的項目單一的操作系統。 這是我Gradle構建:

plugins {
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.5'
}

group 'eu.sample'
version '2.0'

repositories {
mavenCentral()
}

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

mainClassName = "$moduleName/eu.sample.app.Main"

def java_home = hasProperty('org.gradle.java.home') ? getProperty('org.gradle.java.home') : System.getenv('JAVA_HOME')
def fx_jmods = hasProperty('path.to.fx.mods') ? getProperty('path.to.fx.mods') : System.getenv('PATH_TO_FX_MODS')

dependencies {

}

task jlink(type: Exec) {
dependsOn 'clean'
dependsOn 'jar'

workingDir 'build'

if (java_home == null) {
    throw new RuntimeException("java_home is not defined.")
}
if (fx_jmods == null) {
    throw new RuntimeException("fx_jmods is not defined.")
}
commandLine "${java_home}/bin/jlink", '--module-path', "libs${File.pathSeparatorChar}${fx_jmods}",
        '--add-modules', "${moduleName}", '--output', "${moduleName}", '--strip-debug',
        '--compress', '2', '--no-header-files', '--no-man-pages'

}
我添加了。 gradle行,之前火jlinkWin任務我運行清潔任務:

task jlinkWin(type: Exec) {
dependsOn 'clean'
dependsOn 'jar'

workingDir 'build'

if (java_home == null) {
    throw new RuntimeException("java_home is not defined.")
}
if (fx_jmods == null) {
    throw new RuntimeException("fx_jmods is not defined.")
}
commandLine "${java_home}/bin/jlink", '--module-path', "/home/user1/Download/win-jdk-11.0.1/jmods${File.pathSeparatorChar}libs${File.pathSeparatorChar}${fx_jmods}",
        '--add-modules', "${moduleName}", '--output', "${moduleName}", '--strip-debug',
        '--compress', '2', '--no-header-files', '--no-man-pages'

}
好吧我發現解決方案。 更新的代碼上面創建自定義運行時圖像窗口。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章