Skip to content

Commit

Permalink
Add installers (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
jperedadnr authored Oct 25, 2024
1 parent 240b286 commit 7995599
Show file tree
Hide file tree
Showing 7 changed files with 254 additions and 16 deletions.
34 changes: 34 additions & 0 deletions .github/scripts/jpackage.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
set MODULE_NAME=EmbeddedSceneBuilderDemo
set MAIN_CLASS=com.gluonhq.scenebuilder.embedded.demo.DemoApplication

cp target\demo-%APP_VERSION%.jar target\lib\

for /F %%i in ('%JAVA_HOME%\bin\jdeps --module-path target\lib --print-module-deps --ignore-missing-deps -m %MODULE_NAME%') do SET JDEPS_MODULES=%%i

set JAVA_MODULES=javafx.fxml,javafx.media,javafx.swing,javafx.web,java.logging

%JAVA_HOME%\bin\jlink ^
--module-path target\lib ^
--add-modules %JDEPS_MODULES%,%JAVA_MODULES% ^
--output target\runtime ^
--strip-debug --compress zip-6 --no-header-files --no-man-pages

%JPACKAGE_HOME%\bin\jpackage ^
--module-path target/lib ^
--runtime-image target/runtime ^
--dest target/installer ^
--module %MODULE_NAME%/%MAIN_CLASS% ^
--name %MODULE_NAME% ^
--description "Embedded Scene Builder Demo" ^
--vendor "Gluon" ^
--copyright "Copyright © 2024 Gluon" ^
--license-file LICENSE.txt ^
--app-version %APP_VERSION% ^
--java-options '"--add-opens=javafx.fxml/javafx.fxml=com.gluonhq.scenebuilder.kit"' ^
--type msi ^
--win-dir-chooser ^
--win-menu ^
--win-menu-group "Scene Builder" ^
--win-per-user-install ^
--win-shortcut

27 changes: 27 additions & 0 deletions .github/scripts/jpackage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
MODULE_NAME=EmbeddedSceneBuilderDemo
MAIN_CLASS=com.gluonhq.scenebuilder.embedded.demo.DemoApplication

cp target/demo-$APP_VERSION.jar target/lib/

jdeps_modules=$($JAVA_HOME/bin/jdeps --module-path target/lib --print-module-deps --ignore-missing-deps -m $MODULE_NAME)
JAVA_MODULES=javafx.fxml,javafx.media,javafx.swing,javafx.web,java.logging

$JAVA_HOME/bin/jlink \
--module-path target/lib \
--add-modules $jdeps_modules,$JAVA_MODULES \
--output target/runtime \
--strip-debug --compress zip-6 --no-header-files --no-man-pages

$JPACKAGE_HOME/bin/jpackage \
--module-path target/lib \
--runtime-image target/runtime \
--dest target/installer \
--module $MODULE_NAME/$MAIN_CLASS \
--name $MODULE_NAME \
--description "Embedded Scene Builder Demo" \
--vendor "Gluon" \
--copyright "Copyright © 2024 Gluon" \
--license-file LICENSE.txt \
--app-version $APP_VERSION \
--java-options '"--add-opens=javafx.fxml/javafx.fxml=com.gluonhq.scenebuilder.kit"' \
"$@"
159 changes: 159 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
name: Build

on:
push:
branches:
- 'main'
pull_request:
branches:
- 'main'

env:
JAVA_RELEASE: '23'
JAVA_VERSION: '23.0.1'
JAVAFX_VERSION: '23.0.1'
APP_VERSION: '1.0.0'

jobs:
build:
strategy:
matrix:
os: [ macos-13, macos-14, ubuntu-latest, windows-latest ]
include:
- os: macos-13
ARCH: "-amd64"
PLAT: "macos"
FX: "osx-x64"
- os: macos-14
ARCH: "-aarch64"
PLAT: "macos"
FX: "osx-aarch64"
- os: ubuntu-latest
ARCH: ""
PLAT: "linux"
FX: "linux-x64"
- os: windows-latest
ARCH: ""
PLAT: "win"
FX: "windows-x64"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Setup Java
uses: oracle-actions/[email protected]
with:
website: jdk.java.net
release: ${{ env.JAVA_RELEASE }}
version: ${{ env.JAVA_VERSION }}

- uses: Apple-Actions/import-codesign-certs@v3
if: github.event_name != 'pull_request' && (matrix.os == 'macos-13' || matrix.os == 'macos-14')
with:
p12-file-base64: ${{ secrets.CERTIFICATES_FILE_BASE64 }}
p12-password: ${{ secrets.CERTIFICATES_PASSWORD }}

- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Build and package Jar (non-windows)
if: matrix.os != 'windows-latest'
run: mvn -B -ntp -q clean package -Dmaven.test.skip=true

- name: Build and package Jar (windows)
if: matrix.os == 'windows-latest'
shell: cmd
run: call mvn -B -ntp package -Dmaven.test.skip=true

- name: Create Bundle using jpackage for macos
if: matrix.os == 'macos-13' || matrix.os == 'macos-14'
id: outputfile_mac
run: |
if [[ ${{ github.event_name }} != 'pull_request' ]]; then
.github/scripts/jpackage.sh \
--type dmg \
--mac-package-identifier com.gluonhq.scenebuilder.embedded.Demo \
--mac-package-name 'Embedded SB Demo' \
--mac-package-signing-prefix "${{ env.MACSIGN_PREFIX }}" \
--mac-signing-key-user-name "${{ env.MACSIGN_USER }}" \
--mac-sign
else
.github/scripts/build_app_mac.sh \
--type dmg \
--mac-package-identifier com.gluonhq.scenebuilder.embedded.Demo \
--mac-package-name 'Embedded SB Demo'
fi
mv target/installer/EmbeddedSceneBuilderDemo-${{ env.APP_VERSION }}.dmg target/installer/EmbeddedSceneBuilderDemo-${{ env.APP_VERSION }}${{ matrix.ARCH }}.dmg
echo path=target/installer/EmbeddedSceneBuilderDemo-${{ env.APP_VERSION }}${{ matrix.ARCH }}.dmg >> $GITHUB_OUTPUT
env:
JPACKAGE_HOME: ${{ env.JAVA_HOME }}
MACSIGN_PREFIX: ${{ secrets.GLUON_MACSIGN_PREFIX }}
MACSIGN_USER: ${{ secrets.GLUON_MACSIGN_USER }}
APP_VERSION: ${{ env.APP_VERSION }}

- name: Create Bundle using jpackage for linux
if: matrix.os == 'ubuntu-latest'
id: outputfile_linux
run: |
.github/scripts/jpackage.sh \
--type deb
echo path_deb=target/installer/embeddedscenebuilderdemo_${{ env.APP_VERSION }}_amd64.deb >> $GITHUB_OUTPUT
.github/scripts/jpackage.sh \
--type rpm
ls -l target/installer/
echo path_rpm=target/installer/embeddedscenebuilderdemo-${{ env.APP_VERSION }}-1.x86_64.rpm >> $GITHUB_OUTPUT
env:
JPACKAGE_HOME: ${{ env.JAVA_HOME }}
APP_VERSION: ${{ env.APP_VERSION }}

- name: Create Bundle using jpackage for windows
if: matrix.os == 'windows-latest'
id: outputfile_win
shell: cmd
run: |
call .github\scripts\jpackage.bat
echo path=target\installer\EmbeddedSceneBuilderDemo-${{ env.APP_VERSION }}.msi >> %GITHUB_OUTPUT%
env:
JPACKAGE_HOME: ${{ env.JAVA_HOME }}
APP_VERSION: ${{ env.APP_VERSION }}

- name: Notarize Release Build
if: github.event_name != 'pull_request' && (matrix.os == 'macos-13' || matrix.os == 'macos-14')
uses: erwin1/xcode-notarizer@v1
with:
product-path: ${{ steps.outputfile_mac.outputs.path }}
apple-id: ${{ secrets.NOTARIZATION_USERNAME }}
app-password: ${{ secrets.NOTARIZATION_PASSWORD }}
team-id: ${{ secrets.GLUON_MACSIGN_PREFIX }}

- name: Archive jpackage for macos
if: matrix.os == 'macos-13' || matrix.os == 'macos-14'
uses: actions/upload-artifact@v4
with:
name: EmbeddedSceneBuilderDemo-${{ matrix.PLAT }}${{ matrix.ARCH }}
path: ${{ steps.outputfile_mac.outputs.path }}

- name: Archive jpackage for linux deb
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: EmbeddedSceneBuilderDemo-${{ matrix.PLAT }}${{ matrix.ARCH }}-deb
path: ${{ steps.outputfile_linux.outputs.path_deb }}

- name: Archive jpackage for linux rpm
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: EmbeddedSceneBuilderDemo-${{ matrix.PLAT }}${{ matrix.ARCH }}-rpm
path: ${{ steps.outputfile_linux.outputs.path_rpm }}

- name: Archive jpackage for windows
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: EmbeddedSceneBuilderDemo-${{ matrix.PLAT }}${{ matrix.ARCH }}
path: ${{ steps.outputfile_win.outputs.path }}
44 changes: 30 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.gluonhq.scenebuilder.embedded</groupId>
<artifactId>demo</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.0</version>
<name>EmbeddedSceneBuilderDemo</name>

<properties>
Expand All @@ -17,29 +17,24 @@
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.release>${java.version}</maven.compiler.release>
<javafx.version>23.0.1</javafx.version>

</properties>

<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>com.gluonhq.scenebuilder</groupId>
<artifactId>kit</artifactId>
<version>24.0.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.controlsfx</groupId>
Expand Down Expand Up @@ -83,11 +78,32 @@
EmbeddedSceneBuilderDemo/com.gluonhq.scenebuilder.embedded.demo.DemoApplication
</mainClass>
<options>
<option>--add-opens=javafx.fxml/javafx.fxml=EmbeddedSceneBuilderDemo</option>
<option>--add-opens=javafx.fxml/javafx.fxml=com.gluonhq.scenebuilder.kit</option>
</options>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.8.0</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<includeScope>compile</includeScope>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private static boolean isSystemModule(final ModuleReference moduleReference) {
return false;
}
return name.startsWith("java.") || name.startsWith("jdk.") || name.startsWith("javafx.") ||
name.startsWith("oracle.") || name.startsWith("com.gluonhq.scenebuilder.") || "EmbeddedSceneBuilderContainer".equals(name);
name.startsWith("oracle.") || name.startsWith("com.gluonhq.scenebuilder.") || "EmbeddedSceneBuilderDemo".equals(name);
}

public static List<Path> scan() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
import org.controlsfx.control.ToggleSwitch;

public class DemoApplication extends Application {

Expand All @@ -56,7 +57,7 @@ public void start(Stage stage) {
Button saveButton = new Button("Save FXML");
saveButton.setOnAction(sceneBuilderPane.saveFXMLHandler());

HBox top = new HBox(50, newButton, fileButton, saveButton);
HBox top = new HBox(50, newButton, fileButton, saveButton, new ToggleSwitch());
top.setPadding(new Insets(5));
top.setAlignment(Pos.CENTER);

Expand Down
1 change: 1 addition & 0 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
requires javafx.fxml;
requires com.gluonhq.scenebuilder.kit;
requires org.controlsfx.controls;
requires java.logging;

uses com.oracle.javafx.scenebuilder.kit.i18n.spi.I18NResourcesProvider;
opens com.gluonhq.scenebuilder.embedded to javafx.fxml;
Expand Down

0 comments on commit 7995599

Please sign in to comment.