Skip to content

Commit 0e41ce6

Browse files
committed
Add profile for creating an unshaded uberjar
This commit is dedicated to Adrian Wolny.
1 parent 19c9e61 commit 0e41ce6

File tree

1 file changed

+70
-1
lines changed

1 file changed

+70
-1
lines changed

pom.xml

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>org.scijava</groupId>
66
<artifactId>pom-scijava-base</artifactId>
7-
<version>9.0.1-SNAPSHOT</version>
7+
<version>9.1.0-SNAPSHOT</version>
88
<packaging>pom</packaging>
99

1010
<name>SciJava Base POM</name>
@@ -139,6 +139,11 @@
139139
-->
140140
<automatic-module-name>${package-name}</automatic-module-name>
141141

142+
<!--
143+
Name of the uberjar generated by the uberjar profile.
144+
-->
145+
<uberjar-classifier>all</uberjar-classifier>
146+
142147
<!--
143148
The License which license-maven-plugin will use to populate.
144149
See: license:update-file-header, license:update-project-license
@@ -227,6 +232,7 @@
227232
<maven-plugin-plugin.version>3.6.0</maven-plugin-plugin.version>
228233
<maven-release-plugin.version>2.5.3</maven-release-plugin.version>
229234
<maven-resources-plugin.version>3.1.0</maven-resources-plugin.version>
235+
<maven-shade-plugin.version>3.2.1</maven-shade-plugin.version>
230236
<maven-site-plugin.version>3.7.1</maven-site-plugin.version>
231237
<maven-source-plugin.version>3.1.0</maven-source-plugin.version>
232238
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
@@ -458,6 +464,11 @@
458464
<version>${maven-resources-plugin.version}</version>
459465
</plugin>
460466

467+
<plugin>
468+
<artifactId>maven-shade-plugin</artifactId>
469+
<version>${maven-shade-plugin.version}</version>
470+
</plugin>
471+
461472
<plugin>
462473
<artifactId>maven-site-plugin</artifactId>
463474
<version>${maven-site-plugin.version}</version>
@@ -1436,6 +1447,64 @@
14361447
</build>
14371448
</profile>
14381449

1450+
<!--
1451+
The uberjar profile augments the package phase to build an unshaded uber-JAR
1452+
or "fat JAR" using the maven-shade-plugin. The default classifier is "all";
1453+
override the ${uberjar-classifier} property to change it.
1454+
1455+
Uber-JARs are convenient for all-in-one distribution of a Java program,
1456+
freeing users from the burden of juggling multiple files and dependencies.
1457+
However, unshaded uberjars are not appropriate for use as dependencies
1458+
themselves, because the uber-JAR's embedded version of each dependency may
1459+
clash with other classpath components relying on those same dependencies.
1460+
It is advised to publish the standard (non-uber) JAR of your component with
1461+
proper dependency declarations as the main artifact, and deploy the uber-JAR
1462+
as a separate classifier.
1463+
-->
1464+
<profile>
1465+
<id>uberjar</id>
1466+
<build>
1467+
<plugins>
1468+
<plugin>
1469+
<groupId>org.apache.maven.plugins</groupId>
1470+
<artifactId>maven-shade-plugin</artifactId>
1471+
<executions>
1472+
<execution>
1473+
<phase>package</phase>
1474+
<goals>
1475+
<goal>shade</goal>
1476+
</goals>
1477+
<configuration>
1478+
<shadedClassifierName>${uberjar-classifier}</shadedClassifierName>
1479+
<createDependencyReducedPom>false</createDependencyReducedPom>
1480+
<shadedArtifactAttached>true</shadedArtifactAttached>
1481+
<transformers>
1482+
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
1483+
<resource>META-INF/json/org.scijava.plugin.Plugin</resource>
1484+
</transformer>
1485+
</transformers>
1486+
<filters>
1487+
<filter>
1488+
<!--
1489+
Shading signed JARs will fail without this.
1490+
http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
1491+
-->
1492+
<artifact>*:*</artifact>
1493+
<excludes>
1494+
<exclude>META-INF/*.SF</exclude>
1495+
<exclude>META-INF/*.DSA</exclude>
1496+
<exclude>META-INF/*.RSA</exclude>
1497+
</excludes>
1498+
</filter>
1499+
</filters>
1500+
</configuration>
1501+
</execution>
1502+
</executions>
1503+
</plugin>
1504+
</plugins>
1505+
</build>
1506+
</profile>
1507+
14391508
<!--
14401509
The jdb profile launches the defined ${main-class} in the jdb debugger.
14411510
Launch it using: mvn -Pjdb exec:exec

0 commit comments

Comments
 (0)