I want to use maven to create out of two modules jar files, (each as a single fat jar), depending on a third module. My problem is that if I use "mvn package" it does not use the maven-shade-plugin but somehow maven-jar-plugin:2.4:jar (default-jar). Even it isnt anywhere defined to do so. Any ideas why?
Parent-Project POM:
<groupId>com.firstproject.myapp</groupId>
<artifactId>parent-project</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Player Communication Parent Project</name>
<modules>
<module>simple-message</module>
<module>simple-client</module>
<module>simple-server</module>
</modules>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
</dependencies>
<build>
</build>
</project>
simple-client POM
<build>
<finalName>Server</finalName>
<pluginManagement>
<plugins>
<!-- Maven JAR Plugin for TCPServer -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.firstproject.myapp.AppServer</mainClass>
</transformer>
</transformers>
<minimizeJar>false</minimizeJar>
<createDependencyReducedPom>false</createDependencyReducedPom>
<dependencyReducedPomLocation>
${java.io.tmpdir}/dependency-reduced-pom.xml
</dependencyReducedPomLocation>
<relocations>
<relocation>
<pattern>com.firstproject.myapp</pattern>
<shadedPattern>hidden.coyote</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
The maven-jar-plugin is implicitly defined by the life cycle. But this is not your problem.
Your problem is that you put the plugin definition into <pluginManagement>
, which means that the plugin is not actually run. You need to move it to <build><plugins>
.