Created
May 1, 2025 18:54
-
-
Save ahndmal/0b6451fb19dca0c2cb94958cb17d361a to your computer and use it in GitHub Desktop.
maven-jar-exec-examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>org.example</groupId> | |
<artifactId>graal-maven-1</artifactId> | |
<version>0.0.2</version> | |
<properties> | |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
<maven.compiler.source>17</maven.compiler.source> | |
<maven.compiler.target>17</maven.compiler.target> | |
<maven-jar-plugin.version>3.2.2</maven-jar-plugin.version> | |
<native.maven.plugin.version>0.9.13</native.maven.plugin.version> | |
</properties> | |
<dependencies> | |
<dependency> | |
<groupId>junit</groupId> | |
<artifactId>junit</artifactId> | |
<version>4.13.2</version> | |
<scope>test</scope> | |
</dependency> | |
</dependencies> | |
<build> | |
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> | |
<plugins> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-jar-plugin</artifactId> | |
<version>${maven-jar-plugin.version}</version> | |
<configuration> | |
<archive> | |
<manifest> | |
<mainClass>com.andmal.Main</mainClass> | |
</manifest> | |
</archive> | |
</configuration> | |
</plugin> | |
</plugins> | |
</pluginManagement> | |
</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> | |
<imageName>my-app</imageName> | |
<buildArgs> | |
<buildArg>-H:+ReportExceptionStackTraces</buildArg> | |
<!-- <buildArg>-H:+StaticExecutableWithDynamicLibC</buildArg> --> | |
<buildArg>--verbose</buildArg> | |
<!-- For Quick Build (22.1+) --> | |
<buildArg>-Ob</buildArg> | |
</buildArgs> | |
<!-- Start: Workaround for 22.2: Disable the default Java Module Path using USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM --> | |
<!-- <environment> | |
<USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM>false</USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM> | |
</environment> --> | |
<!-- End: Workaround for 22.2: Disable the default Java Module Path using USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM --> | |
</configuration> | |
</plugin> | |
</plugins> | |
</build> | |
</profile> | |
<profile> | |
<id>shaded</id> | |
<build> | |
<plugins> | |
<!-- tag::shade-plugin[] --> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-shade-plugin</artifactId> | |
<version>3.2.4</version> | |
<executions> | |
<execution> | |
<phase>package</phase> | |
<goals> | |
<goal>shade</goal> | |
</goals> | |
<configuration> | |
<shadedArtifactAttached>true</shadedArtifactAttached> | |
</configuration> | |
</execution> | |
</executions> | |
</plugin> | |
<!-- end::shade-plugin[] --> | |
<!-- tag::native-plugin[] --> | |
<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>compile-no-fork</goal> | |
</goals> | |
<phase>package</phase> | |
</execution> | |
</executions> | |
<configuration> | |
<skip>false</skip> | |
<useArgFile>false</useArgFile> | |
<imageName>my app</imageName> | |
<fallback>false</fallback> | |
<classpath> | |
<param>${project.build.directory}/${project.artifactId}-${project.version}-shaded.jar</param> | |
</classpath> | |
</configuration> | |
</plugin> | |
<!-- end::native-plugin[] --> | |
</plugins> | |
</build> | |
</profile> | |
</profiles> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment