From 0603851303363a38ac146c32db5abb9473bb9d8c Mon Sep 17 00:00:00 2001 From: WANG CHAO <1229983126@qq.com> Date: Tue, 19 Feb 2019 23:48:38 +0800 Subject: [PATCH] build.gradle: add javafx runtime dependency for all platforms 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 --- build.gradle | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/build.gradle b/build.gradle index bd9ab7af35f4..e7b06512c8dd 100644 --- a/build.gradle +++ b/build.gradle @@ -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' @@ -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'