add jpackage profile to build a macos app

This commit is contained in:
bea
2026-09-29 12:04:06 +02:00
parent 42dc8bbda8
commit 005f22c581
2 changed files with 77 additions and 0 deletions
+73
View File
@@ -110,4 +110,77 @@
</pluginRepository>
</pluginRepositories>
<profiles>
<!-- builds a native .app bundle. jpackage can only target the os it runs on:
run this profile on macos with `mvn clean package -Pmac-app` -->
<profile>
<id>mac-app</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<id>stage-jpackage-input</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/jpackage-input</outputDirectory>
<resources>
<resource>
<directory>${project.build.directory}</directory>
<includes>
<include>${project.build.finalName}-jar-with-dependencies.jar</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.6.4</version>
<executions>
<execution>
<id>jpackage-app-image</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${java.home}/bin/jpackage</executable>
<arguments>
<argument>--type</argument>
<argument>app-image</argument>
<argument>--name</argument>
<argument>${project.artifactId}</argument>
<argument>--dest</argument>
<argument>${project.build.directory}/jpackage</argument>
<argument>--input</argument>
<argument>${project.build.directory}/jpackage-input</argument>
<argument>--main-jar</argument>
<argument>${project.build.finalName}-jar-with-dependencies.jar</argument>
<argument>--main-class</argument>
<argument>wtf.beatrice.autosqueal.Main</argument>
<argument>--mac-package-identifier</argument>
<argument>wtf.beatrice.autosqueal</argument>
<argument>--mac-package-name</argument>
<argument>autosqueal</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
+4
View File
@@ -29,6 +29,10 @@
2. `cd` into the directory and run `mvn clean package`.
3. you will find a runnable jar with dependencies in the `target/` folder.
4. run the built jar file with `java -jar target/autosqueal-*-jar-with-dependencies.jar`.
**macos .app bundle**
- on macos, run `mvn clean package -Pmac-app`: you will find `autosqueal.app` in `target/jpackage/`.
- the first time you run it, grant it the accessibility and screen recording permissions in system settings, like any other java app.
## support
| category | info |