detect and configure build for headless environments

This commit is contained in:
Craig Raw 2022-10-11 15:12:40 +02:00
parent f3b0d37c54
commit b2d85b6c78

View file

@ -1,3 +1,5 @@
import java.awt.GraphicsEnvironment
plugins { plugins {
id 'application' id 'application'
id 'org-openjfx-javafxplugin' id 'org-openjfx-javafxplugin'
@ -17,6 +19,7 @@ if(System.getProperty("os.arch") == "aarch64") {
osArch = "aarch64" osArch = "aarch64"
targetName = "-" + osArch targetName = "-" + osArch
} }
def headless = GraphicsEnvironment.isHeadless()
group "com.sparrowwallet" group "com.sparrowwallet"
version "${sparrowVersion}" version "${sparrowVersion}"
@ -159,6 +162,9 @@ run {
applicationDefaultJvmArgs += ["-Dprism.lcdtext=false", "-Xdock:name=Sparrow", "-Xdock:icon=/Users/scy/git/sparrow/src/main/resources/sparrow-large.png", applicationDefaultJvmArgs += ["-Dprism.lcdtext=false", "-Xdock:name=Sparrow", "-Xdock:icon=/Users/scy/git/sparrow/src/main/resources/sparrow-large.png",
"--add-opens=javafx.graphics/com.sun.glass.ui.mac=centerdevice.nsmenufx"] "--add-opens=javafx.graphics/com.sun.glass.ui.mac=centerdevice.nsmenufx"]
} }
if(headless) {
applicationDefaultJvmArgs += ["-Dglass.platform=Monocle", "-Dmonocle.platform=Headless", "-Dprism.order=sw"]
}
} }
jlink { jlink {
@ -211,6 +217,9 @@ jlink {
if(os.macOsX) { if(os.macOsX) {
jvmArgs += ["-Dprism.lcdtext=false", "--add-opens=javafx.graphics/com.sun.glass.ui.mac=com.sparrowwallet.merged.module"] jvmArgs += ["-Dprism.lcdtext=false", "--add-opens=javafx.graphics/com.sun.glass.ui.mac=com.sparrowwallet.merged.module"]
} }
if(headless) {
jvmArgs += ["-Dglass.platform=Monocle", "-Dmonocle.platform=Headless", "-Dprism.order=sw"]
}
} }
addExtraDependencies("javafx") addExtraDependencies("javafx")
jpackage { jpackage {