Skip to content

Commit

Permalink
Test building native-image
Browse files Browse the repository at this point in the history
  • Loading branch information
Thihup committed May 7, 2024
1 parent 604a53c commit 61d2fd1
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 5 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: GraalVM build
on: [push, pull_request, workflow_dispatch]
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: graalvm/setup-graalvm@v1
with:
java-version: '22'
distribution: 'graalvm'
cache: 'maven'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Example step
run: |
echo "GRAALVM_HOME: $GRAALVM_HOME"
echo "JAVA_HOME: $JAVA_HOME"
java --version
native-image --version
- name: Compile and package
run: mvn package
- name: Example step using Maven plugin
run: |
cd dev.thihup.jvisualg.ide
mvn -Pnative -Dagent exec:exec@java-agent
mvn -Pnative package
- name: Release
uses: ncipollo/release-action@v1
with:
artifacts: "dev.thihup.jvisualg.ide/target/JVisualG.exe"
replacesArtifacts: true
tag: JVisualg
token: ${{ secrets.GITHUB_TOKEN }}
allowUpdates: true
109 changes: 104 additions & 5 deletions dev.thihup.jvisualg.ide/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@
<artifactId>dev.thihup.jvisualg.ide</artifactId>

<properties>
<maven.compiler.source>22</maven.compiler.source>
<maven.compiler.target>22</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mainClass>dev.thihup.jvisualg.ide.Main</mainClass>
<native.maven.plugin.version>0.9.12</native.maven.plugin.version>
<imageName>JVisualG</imageName>
<javafx.version>22</javafx.version>
</properties>

<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>22</version>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>22</version>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.fxmisc.richtext</groupId>
Expand All @@ -35,4 +36,102 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>java-agent</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<workingDirectory>${project.build.directory}</workingDirectory>
<arguments>
<argument>--add-exports=javafx.graphics/com.sun.javafx.scene.layout=ALL-UNNAMED</argument>
<argument>--add-exports=javafx.graphics/com.sun.javafx.util=ALL-UNNAMED</argument>
<argument>--add-exports=javafx.graphics/com.sun.javafx.application=ALL-UNNAMED</argument>
<argument>--add-exports=javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED</argument>
<argument>--add-exports=javafx.graphics/com.sun.javafx.scene.text=ALL-UNNAMED</argument>
<argument>--add-exports=javafx.base/com.sun.javafx.event=ALL-UNNAMED</argument>
<argument>--add-exports=javafx.base/com.sun.javafx.collections=ALL-UNNAMED</argument>
<argument>--add-exports=javafx.base/com.sun.javafx.binding=ALL-UNNAMED</argument>
<argument>--add-exports=javafx.base/com.sun.javafx=ALL-UNNAMED</argument>
<argument>--add-exports=javafx.graphics/com.sun.javafx.scene.traversal=ALL-UNNAMED</argument>
<argument>--add-exports=javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED</argument>
<argument>--add-exports=javafx.base/com.sun.javafx.logging=ALL-UNNAMED</argument>
<argument>--add-exports=javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED</argument>
<argument>--add-exports=javafx.graphics/com.sun.javafx.geom=ALL-UNNAMED</argument>
<argument>--add-exports=javafx.graphics/com.sun.javafx.scene.input=ALL-UNNAMED</argument>
<argument>-p</argument>
<modulepath/>
<argument>-cp</argument>
<classpath/>
<argument>-DautoClose=true</argument>
<argument>-m</argument>
<argument>dev.thihup.jvisualg.ide/${mainClass}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>native</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${project.build.directory}/${imageName}</executable>
<workingDirectory>${project.build.directory}</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>native</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>${native.maven.plugin.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<id>build-native</id>
<goals>
<goal>build</goal>
</goals>
<phase>package</phase>
</execution>
<execution>
<id>test-native</id>
<goals>
<goal>test</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
<configuration>
<fallback>false</fallback>
<imageName>${imageName}</imageName>
<agent>
<enabled>true</enabled>
<options>
<option>experimental-class-loader-support</option>
</options>
</agent>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.thihup.jvisualg.ide;

import javafx.application.Application;
import javafx.application.Platform;
import javafx.concurrent.Task;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
Expand Down Expand Up @@ -75,6 +76,9 @@ public void start(Stage stage) throws Exception {
stage.setTitle("JVisualG");
stage.setScene(scene);
stage.show();

if (Boolean.getBoolean("autoClose"))
Platform.runLater(stage::close);
}


Expand Down

0 comments on commit 61d2fd1

Please sign in to comment.