Skip to content

Instantly share code, notes, and snippets.

@ennerf
Last active August 31, 2020 08:55
Show Gist options
  • Save ennerf/55838933a15e019d9e62cbac3a2d0304 to your computer and use it in GitHub Desktop.
Save ennerf/55838933a15e019d9e62cbac3a2d0304 to your computer and use it in GitHub Desktop.
Sample pom for using fat jars (e.g. shaded or obfuscated) with the java-fx-maven plugin
<?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.enner.samples</groupId>
<artifactId>packager-with-shade-jar</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<!-- Project setup, properties, dependencies, etc. -->
<!-- ... -->
<build>
<plugins>
<!-- Create uber jar in default location (works with proguard as well) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shaded-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>${project.build.finalName}</finalName>
</configuration>
</execution>
</executions>
</plugin>
<!-- Build native app w/ shaded jar -->
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.8.3</version>
<configuration>
<!-- Various packager settings. See documentation -->
<!-- ... -->
<!-- Use the jar generated from the shade plugin (also keeps manifest) -->
<updateExistingJar>true</updateExistingJar>
<!-- Don't add the lib/ dir -->
<skipCopyingDependencies>true</skipCopyingDependencies>
<!-- Don't add a manifest entry referencing lib/* -->
<useLibFolderContentForManifestClasspath>true</useLibFolderContentForManifestClasspath>
</configuration>
<executions>
<!-- sets up /app directory, manifests, adds deploy dir, icons, etc. -->
<execution>
<id>create-jfxjar</id>
<phase>package</phase>
<goals>
<goal>build-jar</goal>
</goals>
</execution>
<!-- creates a native bundler around the buildjar output -->
<execution>
<id>create-native</id>
<phase>package</phase>
<goals>
<goal>build-native</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment