Skip to content

Commit

Permalink
Update to use JLink / JPackage
Browse files Browse the repository at this point in the history
  • Loading branch information
dhadka committed Dec 25, 2023
1 parent b144d28 commit 55c3dd5
Show file tree
Hide file tree
Showing 15 changed files with 149 additions and 140 deletions.
99 changes: 18 additions & 81 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,96 +2,33 @@ name: Package

on:
push:
branches: [ master ]
workflow_dispatch:

jobs:
java:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'

- name: Maven Package
run: mvn -Pdesktop package

- name: Create distribution
run: |
mkdir staging
mkdir staging/J3
cp -r target/lib/ staging/J3/lib
cp target/j3-*.jar staging/J3/lib
cp -r data/ staging/J3/data
cp -r animations staging/J3/animations
cp package/* staging/J3
- name: Upload
uses: actions/upload-artifact@v4
with:
name: J3
path: staging

native:
package:
strategy:
matrix:
include:
- name: Windows
os: windows-latest
profile: desktop
path: x86_64-windows
exe: j3.exe
- name: Linux
os: ubuntu-latest
profile: desktop
path: x86_64-linux
exe: j3
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Add msbuild to PATH (Windows)
if: runner.os == 'Windows'
uses: microsoft/[email protected]

- name: Visual Studio shell (Windows)
if: runner.os == 'Windows'
uses: egor-tensin/vs-shell@v2

- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt update
sudo apt install libasound2-dev libavcodec-dev libavformat-dev libavutil-dev libgl-dev libgtk-3-dev libpango1.0-dev libxtst-dev
- name: Setup Gluon's GraalVM
uses: gluonhq/setup-graalvm@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

#- name: Gluon License
# uses: gluonhq/gluon-build-license@v1
# with:
# gluon-license: ${{ secrets.GLUON_LICENSE }}

- name: Maven Package
run: mvn -P${{ matrix.profile }} package
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: 18.0.2
distribution: 'zulu'
java-package: 'jdk+fx'
cache: 'maven'

- name: Gluon Build and Package
run: mvn -P${{ matrix.profile }} gluonfx:build gluonfx:package

- name: Create distribution
run: |
mkdir staging
mkdir staging/J3
cp target/gluonfx/${{ matrix.path }}/${{ matrix.exe }} staging/J3
cp -r data/ staging/J3/data
cp -r animations staging/J3/animations
- name: Maven build
run: mvn clean install

- name: Upload
- name: Upload release
uses: actions/upload-artifact@v4
with:
name: J3-${{ matrix.name }}
path: staging
name: J3-${{ runner.os }}
path: |
./target/*.msi
./target/*.dmg
./target/*.deb
20 changes: 0 additions & 20 deletions package/README.md

This file was deleted.

8 changes: 0 additions & 8 deletions package/j3

This file was deleted.

5 changes: 0 additions & 5 deletions package/j3.bat

This file was deleted.

115 changes: 89 additions & 26 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,25 @@
<groupId>org.j3</groupId>
<artifactId>j3</artifactId>
<version>2.0.0</version>
<description>J3 - Java 3D Visualization Tool</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release>
<javafx.version>21</javafx.version>
<javafx.plugin.version>0.0.8</javafx.plugin.version>
<gluonfx.plugin.version>1.0.22</gluonfx.plugin.version>
<charm.version>6.2.2</charm.version>
<attach.version>4.0.16</attach.version>

<app.name>J3</app.name>
<app.version>${project.version}</app.version>
<main.class>j3.GUI</main.class>
<jvm.modules>javafx.controls,java.logging,java.prefs</jvm.modules>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<windows.upgrade.uuid>e110edba-dbba-4f28-9c9b-ec09ad39522c</windows.upgrade.uuid>
<windows.vendor>Project-Platypus</windows.vendor>

<!-- Empty properties to skip signing by default. Set with the macos-sign Maven profile -->
<macos.sign></macos.sign>
<macos.sign.identity></macos.sign.identity>
</properties>

<dependencies>
Expand Down Expand Up @@ -66,11 +75,31 @@
</dependencies>

<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.7.0</version>
</extension>
</extensions>
<resources>
<resource>
<directory>${project.basedir}/src/packaging</directory>
<filtering>true</filtering>
<targetPath>${project.build.directory}/packaging</targetPath>
</resource>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<artifactId>maven-install-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
Expand All @@ -88,33 +117,67 @@
</executions>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>${javafx.plugin.version}</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<mainClass>${main.class}</mainClass>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>com.gluonhq</groupId>
<artifactId>gluonfx-maven-plugin</artifactId>
<version>${gluonfx.plugin.version}</version>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
<target>${gluonfx.target}</target>
<mainClass>${main.class}</mainClass>
<nativeImageArgs>--report-unsupported-elements-at-runtime</nativeImageArgs>
<reflectionList>
<list>com.sun.prism.shader.Solid_TextureRGB_AlphaTest_Loader</list>
</reflectionList>
<resourcesList>
<list>.*\\.properties$</list>
<list>.*\\.cmap$</list>
</resourcesList>
<releaseConfiguration>
<vendor>Project-Platypus</vendor>
</releaseConfiguration>
</configuration>
</plugin>
<plugin>
<groupId>io.github.wiverson</groupId>
<artifactId>jtoolprovider-plugin</artifactId>
<version>1.0.34</version>
<executions>
<execution>
<id>jlink</id>
<phase>package</phase>
<goals>
<goal>java-tool</goal>
</goals>
<configuration>
<toolName>jlink</toolName>
<removeDirectories>${project.build.directory}/jvm-image/</removeDirectories>
<addModules>${jvm.modules}</addModules>
<output>${project.build.directory}/jvm-image</output>
<args>
<arg>--strip-native-commands</arg>
<arg>--no-header-files</arg>
<arg>--strip-debug</arg>
<arg>--no-man-pages</arg>
<arg>--compress=2</arg>
</args>
</configuration>
</execution>
<execution>
<id>jpackage</id>
<phase>install</phase>
<goals>
<goal>java-tool</goal>
</goals>
<configuration>
<toolName>jpackage</toolName>
<writeOutputToLog>true</writeOutputToLog>
<writeErrorsToLog>true</writeErrorsToLog>
<failOnError>true</failOnError>
<removeDirectories>${project.build.directory}/installer-work</removeDirectories>
<args>@${project.build.directory}/packaging/${os.detected.name}-jpackage.txt</args>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
</plugins>
</build>

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added src/packaging/appicon.icns
Binary file not shown.
Binary file added src/packaging/appicon.ico
Binary file not shown.
Binary file added src/packaging/appicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions src/packaging/linux-jpackage.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--name ${app.name}
--icon "${project.basedir}/appicon.png"
--dest "${project.build.directory}"
--main-jar ${project.build.finalName}.jar
--main-class ${main-class}
--input "${project.build.directory}/lib"
--app-version ${app.version}
--runtime-image "${project.build.directory}/jvm-image"
--temp "${project.build.directory}/installer-work"
--app-content "${project.basedir}/data"
--app-content "${project.basedir}/animations"
13 changes: 13 additions & 0 deletions src/packaging/osx-jpackage.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--name ${app.name}
--icon "${project.basedir}/appicon.icns"
--dest "${project.build.directory}"
--main-jar ${project.build.finalName}.jar
--main-class ${main-class}
--input "${project.build.directory}/lib"
--app-version ${app.version}
--runtime-image "${project.build.directory}/jvm-image"
--temp "${project.build.directory}/installer-work"
--app-content "${project.basedir}/data"
--app-content "${project.basedir}/animations"
${macos.sign}
${macos.sign.identity}
18 changes: 18 additions & 0 deletions src/packaging/windows-jpackage.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--type msi
--name ${app.name}
--win-menu
--win-menu-group ${windows.vendor}
--vendor ${windows.vendor}
--icon "${project.basedir}/src/packaging/appicon.ico"
--dest "${project.build.directory}"
--main-jar ${project.build.finalName}.jar
--main-class ${main.class}
--input "${project.build.directory}/lib"
--app-version ${app.version}
--runtime-image "${project.build.directory}/jvm-image"
--temp "${project.build.directory}/installer-work"
--win-upgrade-uuid ${windows.upgrade.uuid}
--description "${project.description}"
--copyright "Copyright ${windows.vendor}"
--app-content "${project.basedir}/data"
--app-content "${project.basedir}/animations"

0 comments on commit 55c3dd5

Please sign in to comment.