Skip to content

Instantly share code, notes, and snippets.

@ecspresso
Created May 8, 2023 07:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ecspresso/709ce4b2db95377b4ab77f77a84c1ef0 to your computer and use it in GitHub Desktop.
Save ecspresso/709ce4b2db95377b4ab77f77a84c1ef0 to your computer and use it in GitHub Desktop.
POM.xml template for creating a fat jar and a Windows executable with launch4j using Maven.
<?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>com.ecspresso</groupId>
<artifactId>${appName}</artifactId>
<version>${version}</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Variables -->
<appName>AppName</appName>
<version>1.0.0</version>
<executable>appname</executable>
<mainClass>package.Main</mainClass>
<icon>icon.ico</icon>
<fileDescription>Creates a fat jar and a windows executable</fileDescription>
<license>GNU General Public License v3.0</license>
<jdkPath>\path\to\jdk</jdkPath>
<jdkPreference>preferJdk</jdkPreference>
<bundledJre64Bit>true</bundledJre64Bit>
<bundledJreAsFallback>true</bundledJreAsFallback>
<runtimeBits>64</runtimeBits>
<minVersion>17.0.0</minVersion>
</properties>
<dependencies>
<dependency>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<version>2.4.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>${mainClass}</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<executions>
<execution>
<id>l4j-clui</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>console</headerType>
<outfile>target/${executable}-${version}.exe</outfile>
<jar>target/${appName}-${version}-jar-with-dependencies.jar</jar>
<errTitle>${appName}</errTitle>
<jre>
<path>${jdkPath}</path>
<bundledJre64Bit>${bundledJre64Bit}</bundledJre64Bit>
<bundledJreAsFallback>${bundledJreAsFallback}</bundledJreAsFallback>
<jdkPreference>${jdkPreference}</jdkPreference>
<runtimeBits>${runtimeBits}</runtimeBits>
<minVersion>${minVersion}</minVersion>
</jre>
<versionInfo>
<fileVersion>${version}.0</fileVersion>
<txtFileVersion>${version}</txtFileVersion>
<fileDescription>${fileDescription}</fileDescription>
<copyright>${license}</copyright>
<productVersion>${version}.0</productVersion>
<txtProductVersion>${version}</txtProductVersion>
<productName>${appName}</productName>
<internalName>${appName}</internalName>
<originalFilename>${executable}.exe</originalFilename>
</versionInfo>
<icon>${icon}</icon>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment