Reputation: 711
I'm running maven 3.6.0 on ubuntu 18.04.
My application’s pom.xml includes this dependency; the associated "neptus" jar is in my local .m2/repository:
<dependencies>
<dependency>
<groupId>pt.lsts.neptus</groupId>
<artifactId>neptus</artifactId>
<version>x.x</version>
</dependency>
My application actually does reference classes from the “neptus” jar file, so I want to include those classes in my project’s uberjar. Therefore the pom.xml also includes this, adapted from http://maven.apache.org/plugins/maven-shade-plugin/examples/includes-excludes.html
<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>
<filters>
<filter>
<artifact>junit:junit</artifact>
<includes>
<include>junit/framework/**</include>
<include>org/junit/**</include>
</includes>
<excludes>
<exclude>org/junit/runners/**</exclude>
</excludes>
</filter>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
Yet the uberjar generated by 'mvn clean package' doesn’t contain any class files from the neptus artifact, and so my app throws java.lang.NoClassDefFoundError for those missing classes.
What am I doing wrong? Thanks!
Upvotes: 0
Views: 269
Reputation: 711
The maven-shade-plugin is ignored by default if that plugin is enclosed within a pluginManagement block, as it is in my case (sorry, not shown in my original post). The shade plugin does get executed if I do this:
% mvn package shade:shade
as described in this thread.
Upvotes: 0