From 81f81e218296897208635cef5b2e544a0ee45ede Mon Sep 17 00:00:00 2001 From: Steve Hannah Date: Thu, 9 Feb 2023 16:33:04 -0800 Subject: [PATCH] Initial commit --- .github/workflows/jdeploy.yml | 30 +++++++++++++++ .gitignore | 6 +++ README.adoc | 45 +++++++++++++++++++++++ package.json | 30 +++++++++++++++ pom.xml | 16 ++++++++ src/main/java/module-info.java | 4 ++ src/main/java/org/openjfx/App.java | 29 +++++++++++++++ src/main/java/org/openjfx/SystemInfo.java | 13 +++++++ 8 files changed, 173 insertions(+) create mode 100644 .github/workflows/jdeploy.yml create mode 100644 .gitignore create mode 100644 README.adoc create mode 100644 package.json create mode 100644 pom.xml create mode 100644 src/main/java/module-info.java create mode 100644 src/main/java/org/openjfx/App.java create mode 100644 src/main/java/org/openjfx/SystemInfo.java diff --git a/.github/workflows/jdeploy.yml b/.github/workflows/jdeploy.yml new file mode 100644 index 0000000..6acd581 --- /dev/null +++ b/.github/workflows/jdeploy.yml @@ -0,0 +1,30 @@ +# This workflow will build a Java project with Maven and bundle them as native app installers with jDeploy +# See https://www.jdeploy.com for more information. + +name: jDeploy CI with Maven + +on: + push: + branches: ['*'] + tags: ['*'] + +jobs: + build: + permissions: + contents: write + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B package --file pom.xml + - name: Build App Installer Bundles + uses: shannah/jdeploy@master + with: + github_token: ${{ github.token }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..42edddb --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +target +node_modules +jdeploy +jdeploy-bundle +jdeploy_bundle +.idea \ No newline at end of file diff --git a/README.adoc b/README.adoc new file mode 100644 index 0000000..ce86943 --- /dev/null +++ b/README.adoc @@ -0,0 +1,45 @@ += jDeploy JavaFX Starter Template + +A project template for a JavaFX project that includes workflows to auto-deploy native app installers for every commit, and every release/tag. + +== Features + +Native Desktop App Installers:: +This project includes a GitHub actions workflow that generates native installers for each branch and release. https://github.com/shannah/jdeploy-javafx-starter/releases/tag/master[See example]. ++ +image::https://github.com/shannah/jdeploy-javafx-starter/wiki/images/master-tag.png[Example Github Release with Native bundles] + +JavaFX 19:: +Based on the official https://openjfx.io/openjfx-docs/#maven[javafx-archetype-simple archetype] developed by the openjfx project. + +Java 17:: +Currently builds for Java 17, but will be updated to support latest LTS release. + +Auto-Updates:: +Native apps will automatically update to the latest version on launch. Bundles created via a Tag or Release will auto-update to the latest release. Bundles created via a commit to a branch, will auto-update to the latest commit on that branch. + +Distribute "Branch-based" apps:: +Each branch will have its own corresponding installer, which will automatically receive updates for that branch. E.g. If you create "dev" and "stage" branches, each will have its own "release". Users of the "stage" app will automatically receive updates to the "stage" branch. Users of the "dev" app will receive updates to the "dev" branch. + +== Getting Started + +See https://github.com/shannah/jdeploy-javafx-starter/wiki/Getting-Started[Getting Started Wiki Page] + +== How it Works + +This template includes a link:.github/workflows/jdeploy.yml[workflow] that will automatically generate native app installers for Windows, Mac, and Linux to track all branches and releases/tags in this repository. This workflow runs on all commits and all tags. + +For "commits", it will generate native bundles in a tag whose name matches the branch name. E.g. Bundles for the "master" branch will be posted in a tag called "master", which will include native bundles that are kept up-to-date with the state of the "master" branch. + +== Native Bundle Configuration + +Native bundles are generated using jDeploy a free, open source tool for deploying Java apps as native bundles. It includes a desktop GUI app for configuring your app. You can customize the icon, splash screen, file type associations, and more. + +https://www.jdeploy.com[Learn more]. + +== Private Repositories + +This template will work out of the box for public repositories. However, releases must be published to a public repository in order for your app to be able to access updates. Therefore, if you are using a private repository, you'll need to make some small changes to the link:.github/workflows/jdeploy.yml[workflow file] to direct it to publish releases to a different repository. + +https://www.jdeploy.com/docs/manual/#_publishing_releases_for_private_repositories[Learn more] + diff --git a/package.json b/package.json new file mode 100644 index 0000000..9482230 --- /dev/null +++ b/package.json @@ -0,0 +1,30 @@ +{ + "bin": { + "sample2-1-0-0": "jdeploy-bundle/jdeploy.js" + }, + "author": "", + "description": "Parent for JavaFX starter project", + "main": "index.js", + "preferGlobal": true, + "repository": "", + "version": "1.0.0", + "jdeploy": { + "jdk": false, + "javaVersion": "17", + "jar": "target/classes/sample2-1.0.0.jar", + "javafx": true, + "title": "sample2" + }, + "dependencies": { + "njre": "^0.2.0", + "shelljs": "^0.8.4" + }, + "license": "ISC", + "name": "sample2", + "files": [ + "jdeploy-bundle" + ], + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + } +} diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..f8dce67 --- /dev/null +++ b/pom.xml @@ -0,0 +1,16 @@ + + + + jdeploy-javafx-starter + ca.weblite + 1.0.7 + + 4.0.0 + com.jdeploy.demos + sample + 1.0.0 + + UTF-8 + org.openjfx.App + + diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java new file mode 100644 index 0000000..1bef042 --- /dev/null +++ b/src/main/java/module-info.java @@ -0,0 +1,4 @@ +module org.openjfx { + requires javafx.controls; + exports org.openjfx; +} \ No newline at end of file diff --git a/src/main/java/org/openjfx/App.java b/src/main/java/org/openjfx/App.java new file mode 100644 index 0000000..54a0f43 --- /dev/null +++ b/src/main/java/org/openjfx/App.java @@ -0,0 +1,29 @@ +package org.openjfx; + +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.scene.control.Label; +import javafx.scene.layout.StackPane; +import javafx.stage.Stage; + +/** + * JavaFX App + */ +public class App extends Application { + + @Override + public void start(Stage stage) { + var javaVersion = SystemInfo.javaVersion(); + var javafxVersion = SystemInfo.javafxVersion(); + + var label = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + "."); + var scene = new Scene(new StackPane(label), 640, 480); + stage.setScene(scene); + stage.show(); + } + + public static void main(String[] args) { + launch(); + } + +} \ No newline at end of file diff --git a/src/main/java/org/openjfx/SystemInfo.java b/src/main/java/org/openjfx/SystemInfo.java new file mode 100644 index 0000000..1a9130f --- /dev/null +++ b/src/main/java/org/openjfx/SystemInfo.java @@ -0,0 +1,13 @@ +package org.openjfx; + +public class SystemInfo { + + public static String javaVersion() { + return System.getProperty("java.version"); + } + + public static String javafxVersion() { + return System.getProperty("javafx.version"); + } + +} \ No newline at end of file