您的位置:首页 > 编程语言 > Java开发

构建Java模块运行时图像对其他操作系统

2018-12-13 17:39 302 查看

我重写我的小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'

}
好吧我发现解决方案。 更新的代码上面创建自定义运行时图像窗口。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Java 操作系统