Skip to content

Commit

Permalink
build.gradle: add javafx runtime dependency for all platforms
Browse files Browse the repository at this point in the history
We have added the platform-specific javafx runtime dependencies, so the
addressbook is able to run locally.

However, the jar file generated on one OS cannot run on other OS. The
reason is that, after detecting the OS, javafx will try to load
platform-specific classes dynamically. Without corresponding javafx
dependencies for that other OS, the class loading process will fail.

Let's add the javafx runtime dependency for all platforms (MacOS,
Window, Linux) so the jar file generated on one OS is able to run in
other OS [1].

[1] https://stackoverflow.com/questions/52653836/maven-shade-javafx-runtime-components-are-missing/52654791#52654791
  • Loading branch information
fzdy1914 committed Apr 2, 2019
1 parent e6390a4 commit 0603851
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,8 @@
// For more details take a look at the Java Quickstart chapter in the Gradle
// user guide available at http://gradle.org/docs/5.2.1/userguide/tutorial_java_projects.html

import org.apache.commons.lang3.SystemUtils
import org.gradle.api.tasks.testing.logging.TestLogEvent

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'org.apache.commons', name: 'commons-lang3', version: '3.8.1'
}
}

plugins {
id 'java'
id 'jacoco'
Expand Down Expand Up @@ -51,25 +41,29 @@ test {
useJUnitPlatform()
}

String platform = SystemUtils.IS_OS_WINDOWS ? 'win'
: SystemUtils.IS_OS_LINUX ? 'linux'
: SystemUtils.IS_OS_MAC ? 'mac'
: null
if (platform == null) {
println 'The current OS is not supported.'
}

dependencies {
String testFxVersion = '4.0.15-alpha'
String jUnitVersion = '5.1.0'
String javafxVersion = '11'

implementation group: 'org.openjfx', name: 'javafx-base', version: javafxVersion, classifier: platform
implementation group: 'org.openjfx', name: 'javafx-controls', version: javafxVersion, classifier: platform
implementation group: 'org.openjfx', name: 'javafx-fxml', version: javafxVersion, classifier: platform
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javafxVersion, classifier: platform
implementation group: 'org.openjfx', name: 'javafx-media', version: javafxVersion, classifier: platform
implementation group: 'org.openjfx', name: 'javafx-web', version: javafxVersion, classifier: platform
implementation group: 'org.openjfx', name: 'javafx-base', version: javafxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-base', version: javafxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-base', version: javafxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javafxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javafxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javafxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-fxml', version: javafxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-fxml', version: javafxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-fxml', version: javafxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javafxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javafxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javafxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-media', version: javafxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-media', version: javafxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-media', version: javafxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-web', version: javafxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-web', version: javafxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-web', version: javafxVersion, classifier: 'linux'

implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.7.0'
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.7.4'
Expand Down

0 comments on commit 0603851

Please sign in to comment.