mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-04-06 18:20:26 +08:00
Automatically download OpenJFX when JavaFX is missing
This commit is contained in:
parent
01158c2320
commit
6ac8519a9f
@ -175,6 +175,7 @@ processResources {
|
||||
def bssFile = new File(this.projectDir, "build/compiled-resources/" + resource[0..-4] + "bss")
|
||||
bssFile.parentFile.mkdirs()
|
||||
javaexec {
|
||||
classpath = sourceSets.main.compileClasspath
|
||||
mainClass = "com.sun.javafx.css.parser.Css2Bin"
|
||||
args = [cssFile, bssFile]
|
||||
}
|
||||
|
61
build.gradle
61
build.gradle
@ -66,6 +66,67 @@ var jfxUnsupported = [
|
||||
'linux-arm32-monocle': ['media', 'web']
|
||||
]
|
||||
|
||||
var jfxInClasspath = false
|
||||
|
||||
try {
|
||||
Class.forName("javafx.application.Application", false, this.getClass().getClassLoader())
|
||||
jfxInClasspath = true
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
|
||||
if (!jfxInClasspath && JavaVersion.current() >= JavaVersion.VERSION_11) {
|
||||
String os = null
|
||||
String arch = null
|
||||
|
||||
String osName = System.getProperty("os.name").toLowerCase(Locale.US)
|
||||
if (osName.contains("win"))
|
||||
os = 'win'
|
||||
else if (osName.contains("mac"))
|
||||
os = 'mac'
|
||||
else if (osName.contains("solaris") || osName.contains("linux") || osName.contains("unix") || osName.contains("sunos"))
|
||||
os = 'linux'
|
||||
else
|
||||
os = null
|
||||
|
||||
String archName = System.getProperty("os.arch").toLowerCase(Locale.US)
|
||||
switch (archName) {
|
||||
case "x86_64":
|
||||
case "x86-64":
|
||||
case "amd64":
|
||||
arch = ''
|
||||
break
|
||||
case "x86":
|
||||
case "x86_32":
|
||||
case "x86-32":
|
||||
case "i386":
|
||||
case "i486":
|
||||
case "i586":
|
||||
case "i686":
|
||||
case "i86pc":
|
||||
arch = '-x86'
|
||||
break
|
||||
case "aarch64":
|
||||
arch = '-aarch64';
|
||||
break
|
||||
}
|
||||
String platform = "$os$arch"
|
||||
|
||||
if (os != null && arch != null && jfxArches.contains(platform)) {
|
||||
var jfxDependencies = jfxModules.collect { module -> "org.openjfx:javafx-$module:$jfxVersion:$platform" }
|
||||
|
||||
subprojects {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
jfxDependencies.forEach {
|
||||
compileOnly it
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
import com.google.gson.*
|
||||
|
||||
task 'generateOpenJFXDependencies' {
|
||||
|
Loading…
x
Reference in New Issue
Block a user