From 8ccd10d82072f45d53d981a8f18c27cc31dd0295 Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Thu, 29 Aug 2019 23:07:53 -0700 Subject: [PATCH 1/3] Fix typos in moduleName in 2 places --- jgnash-core/build.gradle | 2 +- jgnash-resources/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jgnash-core/build.gradle b/jgnash-core/build.gradle index 4c79cbd95..3e2de2225 100644 --- a/jgnash-core/build.gradle +++ b/jgnash-core/build.gradle @@ -1,7 +1,7 @@ description = "jGnash Core" project.ext { - moduleName = "jgnash-core" + moduleName = "jgnash.core" } dependencies { diff --git a/jgnash-resources/build.gradle b/jgnash-resources/build.gradle index bc263336c..1bb419ee7 100644 --- a/jgnash-resources/build.gradle +++ b/jgnash-resources/build.gradle @@ -4,7 +4,7 @@ import static org.gradle.internal.os.OperatingSystem.* description = "jGnash Resources" project.ext { - moduleName = "jgnash.convert" + moduleName = "jgnash.resources" javaVersion = Jvm.current() osName = current() From f1c20e75425849fef060eef53700b8bc04bc3430 Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Thu, 29 Aug 2019 23:28:07 -0700 Subject: [PATCH 2/3] Move main class to new package: jgnash.app --- bootloader/src/main/java/jGnash.java | 1 + jgnash-fx/src/main/java/{ => jgnash/app}/jGnashFx.java | 1 + jgnash-fx/src/main/resources/META-INF/MANIFEST.MF | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) rename jgnash-fx/src/main/java/{ => jgnash/app}/jGnashFx.java (99%) diff --git a/bootloader/src/main/java/jGnash.java b/bootloader/src/main/java/jGnash.java index 1e2ea65c7..1d77eb92b 100644 --- a/bootloader/src/main/java/jGnash.java +++ b/bootloader/src/main/java/jGnash.java @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +import jgnash.app.jGnashFx; import jgnash.bootloader.BootLoader; import jgnash.bootloader.BootLoaderDialog; diff --git a/jgnash-fx/src/main/java/jGnashFx.java b/jgnash-fx/src/main/java/jgnash/app/jGnashFx.java similarity index 99% rename from jgnash-fx/src/main/java/jGnashFx.java rename to jgnash-fx/src/main/java/jgnash/app/jGnashFx.java index 6f5e2b284..ac8d32a1f 100644 --- a/jgnash-fx/src/main/java/jGnashFx.java +++ b/jgnash-fx/src/main/java/jgnash/app/jGnashFx.java @@ -15,6 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ +package jgnash.app; import java.io.File; import java.io.FileNotFoundException; diff --git a/jgnash-fx/src/main/resources/META-INF/MANIFEST.MF b/jgnash-fx/src/main/resources/META-INF/MANIFEST.MF index e66b94338..df4ec2b77 100644 --- a/jgnash-fx/src/main/resources/META-INF/MANIFEST.MF +++ b/jgnash-fx/src/main/resources/META-INF/MANIFEST.MF @@ -1,4 +1,4 @@ Manifest-Version: 1.0 Application-Name: jGnashFx JavaFX-Application-Class: jGnashFx -Main-Class: jGnashFx +Main-Class: jgnash.app.jGnashFx From b211b9d04728b0fbe081e10d400d4cbac7722287 Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Fri, 30 Aug 2019 16:45:11 -0700 Subject: [PATCH 3/3] WIP: Modular app with jlink/jpackage build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This uses the Badass JLink Gradle Plugin What works: To build the packaged app: ./gradlew build jgnash-fx:jpackage -x test The packaged app will crash on start, needs more debugging To run the modular app via Gradle: ./gradlew jgnash-fx:run The app will start and display a window, but will crash on New or Open Note: You’ll need the jpackage build from JDK 14 installed in the directory pointed to by the env variable `BADASS_JLINK_JPACKAGE_HOME` --- jgnash-fx/build.gradle | 89 ++++++++----------- .../src/main/java/jgnash/app/jGnashFx.java | 4 + .../java/jgnash/uifx/views/main/MainView.java | 15 +++- jgnash-fx/src/main/java/module-info.java | 27 ++++++ 4 files changed, 81 insertions(+), 54 deletions(-) create mode 100644 jgnash-fx/src/main/java/module-info.java diff --git a/jgnash-fx/build.gradle b/jgnash-fx/build.gradle index 85ece6bf7..fef2bbb23 100644 --- a/jgnash-fx/build.gradle +++ b/jgnash-fx/build.gradle @@ -1,12 +1,17 @@ plugins { + id 'application' id "org.openjfx.javafxplugin" + id 'org.beryx.jlink' version '2.15.1' + id 'org.javamodularity.moduleplugin' version "1.5.0" } -apply plugin: "distribution" -apply plugin: "application" // creates a task to run the full application - description = "jGnash JavaFx" -mainClassName = "jGnashFx" + +application { + mainClassName = "$moduleName/jgnash.app.jGnashFx" + applicationName = 'jGnashFx' +} + dependencies { //compile project(":jgnash-manual") @@ -16,42 +21,7 @@ dependencies { compile project(":jgnash-plugin") compile group: "info.picocli", name: "picocli", version: picocliVersion - - // Hack to include all javafx platforms in the classpath - // The platform specific libraries are excluded when distributions is assembled - compile "org.openjfx:javafx-base:" + javaFXVersion - compile "org.openjfx:javafx-controls:" + javaFXVersion - compile "org.openjfx:javafx-fxml:" + javaFXVersion - compile "org.openjfx:javafx-graphics:" + javaFXVersion - compile "org.openjfx:javafx-media:" + javaFXVersion - compile "org.openjfx:javafx-swing:" + javaFXVersion - compile "org.openjfx:javafx-web:" + javaFXVersion - - compile "org.openjfx:javafx-base:" + javaFXVersion + ":linux" - compile "org.openjfx:javafx-controls:" + javaFXVersion + ":linux" - compile "org.openjfx:javafx-fxml:" + javaFXVersion + ":linux" - compile "org.openjfx:javafx-graphics:" + javaFXVersion + ":linux" - compile "org.openjfx:javafx-media:" + javaFXVersion + ":linux" - compile "org.openjfx:javafx-swing:" + javaFXVersion + ":linux" - compile "org.openjfx:javafx-web:" + javaFXVersion + ":linux" - - compile "org.openjfx:javafx-base:" + javaFXVersion + ":win" - compile "org.openjfx:javafx-controls:" + javaFXVersion + ":win" - compile "org.openjfx:javafx-fxml:" + javaFXVersion + ":win" - compile "org.openjfx:javafx-graphics:" + javaFXVersion + ":win" - compile "org.openjfx:javafx-media:" + javaFXVersion + ":win" - compile "org.openjfx:javafx-swing:" + javaFXVersion + ":win" - compile "org.openjfx:javafx-web:" + javaFXVersion + ":win" - - compile "org.openjfx:javafx-base:" + javaFXVersion + ":mac" - compile "org.openjfx:javafx-controls:" + javaFXVersion + ":mac" - compile "org.openjfx:javafx-fxml:" + javaFXVersion + ":mac" - compile "org.openjfx:javafx-graphics:" + javaFXVersion + ":mac" - compile "org.openjfx:javafx-media:" + javaFXVersion + ":mac" - compile "org.openjfx:javafx-swing:" + javaFXVersion + ":mac" - compile "org.openjfx:javafx-web:" + javaFXVersion + ":mac" - // end hack - + // required of Unit testing JavaFX testCompile group: 'org.testfx', name: 'testfx-junit5', version: '4.0.15-alpha' testCompile group: 'org.testfx', name: 'openjfx-monocle', version: 'jdk-12.0.1+2' @@ -84,17 +54,6 @@ distZip { } } -distributions { - main { - baseName = "jGnash" - contents { - exclude("**/*-linux*") // excludes linux specific JavaFx modules from cross platform zip - exclude("**/*-win*") // excludes windows specific JavaFx modules from cross platform zip - exclude("**/*-mac*") // excludes mac specific JavaFx modules from cross platform zip - } - } -} - jar { // Keep jar clean: exclude "META-INF/*.SF", "META-INF/*.DSA", "META-INF/*.RSA", "META-INF/*.MF" @@ -104,3 +63,31 @@ jar { "Class-Path": configurations.runtimeClasspath.files.collect { "lib/$it.name" }.join(" ") } } + +jlink { + addExtraDependencies("javafx") + options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages'] + launcher { + name = applicationName + jvmArgs = [] + } + mergedModule { + requires 'java.logging' + + requires 'javafx.controls' + requires 'javafx.fxml' + requires 'javafx.web' + requires 'javafx.swing' + requires 'javafx.graphics' + requires 'javafx.media' + } + jpackage { + // See https://badass-jlink-plugin.beryx.org/releases/latest/#_jpackage for + // where the plugin's jpackage task finds the path to the jpackage tool by default + // (Currently you need to manually install a OpenJDK 14 Early Access Build including jpackage) + jpackageHome = System.getenv('BADASS_JLINK_JPACKAGE_HOME') + skipInstaller = false + identifier = applicationName + } +} + diff --git a/jgnash-fx/src/main/java/jgnash/app/jGnashFx.java b/jgnash-fx/src/main/java/jgnash/app/jGnashFx.java index ac8d32a1f..67901cb7f 100644 --- a/jgnash-fx/src/main/java/jgnash/app/jGnashFx.java +++ b/jgnash-fx/src/main/java/jgnash/app/jGnashFx.java @@ -92,6 +92,10 @@ public static void main(final String[] args) { Thread.setDefaultUncaughtExceptionHandler(new StaticUIMethods.ExceptionHandler()); final CommandLine commandLine = new CommandLine(new CommandLineOptions()); + // Hack: Allow unmatched arguments due to Gradle -- because of xx plugin(s)? -- is putting the following args + // '-Dfile.encoding=UTF-8', '-Duser.country=US', '-Duser.language=en', '-Duser.variant' at the + // end of the JavaExec command line for :run task + commandLine.setUnmatchedArgumentsAllowed(true); commandLine.setToggleBooleanFlags(false); commandLine.setUsageHelpWidth(80); diff --git a/jgnash-fx/src/main/java/jgnash/uifx/views/main/MainView.java b/jgnash-fx/src/main/java/jgnash/uifx/views/main/MainView.java index 6b5d3cf3d..a1c56b2c5 100644 --- a/jgnash-fx/src/main/java/jgnash/uifx/views/main/MainView.java +++ b/jgnash-fx/src/main/java/jgnash/uifx/views/main/MainView.java @@ -166,8 +166,14 @@ public void start(final Stage stage, @Nullable final File dataFile, final char[] busyPane = new BusyPane(); - final FXMLLoader fxmlLoader = new FXMLLoader(MenuBarController.class.getResource("MainMenuBar.fxml"), resources); - menuBar = fxmlLoader.load(); + // It's nice to have some logging output when stuff fails in the FX start() method, and this code + // was failing as I was debugging module-info.java + try { + final FXMLLoader fxmlLoader = new FXMLLoader(MenuBarController.class.getResource("MainMenuBar.fxml"), resources); + menuBar = fxmlLoader.load(); + } catch (Exception e) { + logger.log(Level.SEVERE, e.getLocalizedMessage(), e); + } final ToolBar mainToolBar = FXMLLoader.load(MainToolBarController.class.getResource("MainToolBar.fxml"), resources); @@ -193,7 +199,10 @@ public void start(final Stage stage, @Nullable final File dataFile, final char[] scene.getRoot().styleProperty().bind(ThemeManager.styleProperty()); stage.setTitle(TITLE); - stage.getIcons().add(StaticUIMethods.getApplicationIcon()); + // Hack: Comment out this line so `./gradlew :jgnash-fx:run` can at least start the app + // The hack is just kicking the can down the road as the app will crash later when the icon is expected + // to be non-null + //stage.getIcons().add(StaticUIMethods.getApplicationIcon()); stage.setScene(scene); stage.setResizable(true); diff --git a/jgnash-fx/src/main/java/module-info.java b/jgnash-fx/src/main/java/module-info.java new file mode 100644 index 000000000..3dbe3494c --- /dev/null +++ b/jgnash-fx/src/main/java/module-info.java @@ -0,0 +1,27 @@ +module jgnashfx { + requires java.logging; + requires java.prefs; + requires java.desktop; + requires java.scripting; + + requires javafx.base; + requires javafx.controls; + requires javafx.fxml; + requires javafx.web; + requires javafx.swing; + requires javafx.graphics; + requires javafx.media; + + requires info.picocli; + + requires jgnash.resources; + + exports jgnash.app; + exports jgnash.uifx; + + opens jgnash.uifx to javafx.fxml, java.base; + opens jgnash.uifx.views.main to javafx.fxml; + opens jgnash.uifx.resource.font to javafx.fxml; + opens jgnash.uifx.control to javafx.fxml; + opens jgnash.app to javafx.fxml, java.base, info.picocli; +} \ No newline at end of file