Skip to content

Commit 31779c3

Browse files
committed
add JavaFX dependency for higher Java versiosn on build
1 parent 8c28c78 commit 31779c3

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

build.gradle

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,27 @@ apply plugin: 'maven-publish'
88
group 'de.inetsoftware'
99
archivesBaseName = 'jwebassembly-api'
1010
version = '0.2'
11+
sourceCompatibility = 1.8
12+
targetCompatibility = 1.8
1113

1214
repositories {
1315
jcenter()
1416
}
1517

1618
dependencies {
1719
compileOnly 'com.google.code.findbugs:jsr305:3.0.1'
20+
21+
// dependencies for the emulator
1822
compileOnly 'org.ow2.asm:asm:+'
23+
def fxVersion = getJavaFxVersion()
24+
if( fxVersion > 8 ) { // version 8 is build into the OpenJDK
25+
// JavaFX depends the platform and JDK version
26+
def platform = getJavaFxPlatform()
27+
def modules = ['javafx-base', 'javafx-graphics', 'javafx-web']
28+
for (String module : modules) {
29+
compileOnly 'org.openjfx:' + module + ':' + fxVersion + '.+:' + platform
30+
}
31+
}
1932
}
2033

2134
sourceSets {
@@ -29,6 +42,31 @@ sourceSets {
2942
}
3043
}
3144

45+
/**
46+
* The String for Javafx classifier
47+
*/
48+
def getJavaFxPlatform() {
49+
def osname = System.properties['os.name'].toLowerCase()
50+
if( osname.contains( 'windows' ) ) {
51+
return 'win'
52+
} else if( osname.contains( 'mac' ) ) {
53+
return 'mac'
54+
}
55+
return 'linux'
56+
}
57+
58+
/**
59+
* The Javafx version that is compatible with the current JDK
60+
*/
61+
def getJavaFxVersion() {
62+
def fxVersion = org.gradle.util.VersionNumber.parse( System.properties['java.version'] ).getMajor()
63+
if( fxVersion > 8 && fxVersion < 11 ) {
64+
// There is no version 9 and 10, version 8 is build into the OpenJDK
65+
fxVersion = 11
66+
}
67+
return fxVersion;
68+
}
69+
3270
jar {
3371
manifest {
3472
attributes( 'Implementation-Title': 'JWebAssembly-API',

0 commit comments

Comments
 (0)