Skip to content

Commit

Permalink
feat: compile to native
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Vullriede committed Dec 6, 2024
1 parent c7e19d7 commit f0df8eb
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 134 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/build-release-on-main-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,23 @@ jobs:
fetch-depth: 0
fetch-tags: true

- id: setup-jdk
uses: actions/setup-java@v4
- id: setup-graalvm
uses: graalvm/setup-[email protected]
with:
java-version: 21
distribution: 'temurin'
distribution: 'liberica'
java-version: '23'
java-package: 'jdk+fx'
cache: 'maven'

- id: show-paths
run: |
echo "GRAALVM_HOME: $GRAALVM_HOME"
echo "JAVA_HOME: $JAVA_HOME"
java --version
native-image --version
- id: maven-build-verify
run: mvn --batch-mode -Posslabz-release -Pnative-jpackage clean verify
run: mvn --batch-mode -Pnative-graalvm-default clean package

- id: configure-git-user
uses: qoomon/actions--setup-git@v1
Expand Down
187 changes: 91 additions & 96 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>net.osslabz</groupId>
<artifactId>log-gazer</artifactId>
<version>1.1.5</version>
<version>1.1.6</version>

<properties>
<osslabz.encoding>UTF-8</osslabz.encoding>
Expand All @@ -16,7 +17,7 @@
<project.build.outputTimestamp>2024-12-02T20:20:06Z</project.build.outputTimestamp>
<maven.compiler.release>${osslabz.java.version}</maven.compiler.release>

<mainClass>net.osslabz.loggazer.AppStarter</mainClass>
<mainClass>net.osslabz.loggazer.LogGazerApp</mainClass>

<jpackage.maven.plugin.version>1.6.5</jpackage.maven.plugin.version>
</properties>
Expand Down Expand Up @@ -104,7 +105,8 @@
<tagNameFormat>@{project.version}</tagNameFormat>
<scmCommentPrefix>[release]</scmCommentPrefix>
<scmReleaseCommitComment>@{prefix} set version to @{releaseLabel}</scmReleaseCommitComment>
<scmDevelopmentCommitComment>@{prefix} prepare for next development iteration</scmDevelopmentCommitComment>
<scmDevelopmentCommitComment>@{prefix} prepare for next development iteration
</scmDevelopmentCommitComment>

<!-- settings from the conventional-commits-version-policy -->
<projectVersionPolicyId>ConventionalCommitsVersionPolicy</projectVersionPolicyId>
Expand All @@ -121,6 +123,28 @@
<id>native-graalvm-default</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>java-agent</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<workingDirectory>${project.build.directory}</workingDirectory>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>${mainClass}</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
Expand All @@ -137,22 +161,13 @@
</executions>
<configuration>
<mainClass>${mainClass}</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>native-graalvm-gluon</id>
<build>
<plugins>
<plugin>
<groupId>com.gluonhq</groupId>
<artifactId>gluonfx-maven-plugin</artifactId>
<version>1.0.24</version>
<configuration>
<graalvmHome>/Users/ravu/.sdkman/candidates/java/22.1.0.1.r17-gln</graalvmHome>
<mainClass>${mainClass}</mainClass>
<fallback>false</fallback>
<agent>
<enabled>true</enabled>
</agent>
<jvmArgs>
<arg>-Djava.awt.headless=false</arg>
</jvmArgs>
</configuration>
</plugin>
</plugins>
Expand All @@ -168,13 +183,25 @@
<build>
<plugins>
<plugin>
<groupId>org.panteleyev</groupId>
<artifactId>jpackage-maven-plugin</artifactId>
<version>${jpackage.maven.plugin.version}</version>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.7.1</version>
<configuration>
<type>MSI</type>
<icon>${project.build.outputDirectory}/icon/icon-256.png</icon>
<winMenu>true</winMenu>
<finalName>${project.artifactId}-${project.version}-${os.detected.classifier}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<inlineDescriptors>
<inlineDescriptor>
<id>compress</id>
<formats>
<format>zip</format>
</formats>
<files>
<file>
<source>${project.build.directory}/log-gazer.exe</source>
<outputDirectory></outputDirectory>
</file>
</files>
</inlineDescriptor>
</inlineDescriptors>
</configuration>
</plugin>
</plugins>
Expand All @@ -190,12 +217,25 @@
<build>
<plugins>
<plugin>
<groupId>org.panteleyev</groupId>
<artifactId>jpackage-maven-plugin</artifactId>
<version>${jpackage.maven.plugin.version}</version>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.7.1</version>
<configuration>
<type>DEB</type>
<icon>${project.build.outputDirectory}/icon/icon-256.png</icon>
<finalName>${project.artifactId}-${project.version}-${os.detected.classifier}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<inlineDescriptors>
<inlineDescriptor>
<id>compress</id>
<formats>
<format>tar.gz</format>
</formats>
<files>
<file>
<source>${project.build.directory}/log-gazer</source>
<outputDirectory></outputDirectory>
</file>
</files>
</inlineDescriptor>
</inlineDescriptors>
</configuration>
</plugin>
</plugins>
Expand All @@ -211,74 +251,30 @@
<build>
<plugins>
<plugin>
<groupId>org.panteleyev</groupId>
<artifactId>jpackage-maven-plugin</artifactId>
<version>${jpackage.maven.plugin.version}</version>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.7.1</version>
<configuration>
<type>DMG</type>
<icon>${project.build.outputDirectory}/icon/log-gazer.icns</icon>
<finalName>${project.artifactId}-${project.version}-${os.detected.classifier}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<inlineDescriptors>
<inlineDescriptor>
<id>compress</id>
<formats>
<format>tar.gz</format>
</formats>
<files>
<file>
<source>${project.build.directory}/log-gazer</source>
<outputDirectory></outputDirectory>
</file>
</files>
</inlineDescriptor>
</inlineDescriptors>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>native-jpackage</id>
<build>
<plugins>
<plugin>
<groupId>org.panteleyev</groupId>
<artifactId>jpackage-maven-plugin</artifactId>
<version>${jpackage.maven.plugin.version}</version>
<configuration>
<destination>${project.build.directory}/dist</destination>
<input>${project.build.directory}</input>
<mainJar>${project.artifactId}-${project.version}.jar</mainJar>
<mainClass>${mainClass}</mainClass>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jpackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>rename-artifact</id>
<phase>verify</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<!-- Define Properties for OS and Architecture -->
<property name="os.classifier" value="${os.detected.classifier}" />

<!-- Rename all files in /target/dist -->
<fileset dir="${project.build.directory}/dist">
<!-- Include all files in the directory -->
<include name="*.*" />
</fileset>

<move todir="${project.build.directory}/dist">
<fileset dir="${project.build.directory}/dist" />
<mapper type="regexp" from="^(.*)\.(.*)$" to="\1-${os.classifier}.\2" />
</move>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<build>
Expand Down Expand Up @@ -315,11 +311,11 @@
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>${mainClass}</mainClass>
</transformer>
</transformers>
<!-- <shadedClassifierName>${os.detected.classifier}</shadedClassifierName>-->
</configuration>
</execution>
</executions>
Expand All @@ -329,7 +325,6 @@
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<!-- <classifier>${os.detected.classifier}</classifier>-->
<archive>
<manifest>
<mainClass>${mainClass}</mainClass>
Expand Down
21 changes: 0 additions & 21 deletions src/main/java/module-info.java

This file was deleted.

30 changes: 19 additions & 11 deletions src/main/java/net/osslabz/loggazer/LogGazerApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import javafx.application.Application;
import javafx.concurrent.Task;
import javafx.scene.Scene;
Expand Down Expand Up @@ -84,13 +85,19 @@ public static void main(String[] args) {
public void start(Stage primaryStage) {

if (Taskbar.isTaskbarSupported()) {
log.debug("Taskbar is supported");
var taskbar = Taskbar.getTaskbar();

if (taskbar.isSupported(Taskbar.Feature.ICON_IMAGE)) {
log.debug("Taskbar.Feature.ICON_IMAGE is supported");
final Toolkit defaultToolkit = Toolkit.getDefaultToolkit();
var dockIcon = defaultToolkit.getImage(getClass().getResource("/icon/icon-256.png"));
taskbar.setIconImage(dockIcon);
} else {
log.debug("Taskbar.Feature.ICON_IMAGE is NOT supported");
}
} else {
log.debug("Taskbar is NOT supported");
}

primaryStage.setTitle(LOG_GAZER);
Expand Down Expand Up @@ -168,15 +175,15 @@ private ToolBar createToolBar() {
resetSearch();

toolBar.getItems().addAll(
this.buttonFormatJson,
new Separator(),
this.buttonMarkLogLevel,
new Separator(),
this.searchField,
this.searchButton,
this.prevMatchButton,
this.nextMatchButton,
this.matchCountLabel
this.buttonFormatJson,
new Separator(),
this.buttonMarkLogLevel,
new Separator(),
this.searchField,
this.searchButton,
this.prevMatchButton,
this.nextMatchButton,
this.matchCountLabel

);

Expand Down Expand Up @@ -229,7 +236,8 @@ private void navigateToCurrentMatch() {
int currentMatchIndex = tabContent.getSearchData().getCurrentMatchIndex();
int numMatches = tabContent.getSearchData().numMatches();

searchField.setText(StringUtils.isNotBlank(tabContent.getSearchData().getQuery()) ? tabContent.getSearchData().getQuery() : SEARCH_QUERY_PLACEHOLDER);
searchField.setText(StringUtils.isNotBlank(tabContent.getSearchData().getQuery()) ? tabContent.getSearchData().getQuery() :
SEARCH_QUERY_PLACEHOLDER);
matchCountLabel.setText(String.format("%d of %d matches", currentMatchIndex + 1, numMatches));

if (currentMatchIndex >= 0 && currentMatchIndex < numMatches) {
Expand Down Expand Up @@ -462,7 +470,7 @@ private void openFile() {
new FileChooser.ExtensionFilter("Compressed Files", "*.gz", "*.zip", "*.tar.gz")
*/
new FileChooser.ExtensionFilter("Files", "*.*")
new FileChooser.ExtensionFilter("Files", "*.*")

);
File file = fileChooser.showOpenDialog(null);
Expand Down
1 change: 0 additions & 1 deletion src/main/java/net/osslabz/loggazer/package-info.java

This file was deleted.

0 comments on commit f0df8eb

Please sign in to comment.