I use maven-shade-plugin
in my java project.
I have a module called core
and i would like to pack all its dependencies into one single jar. I don't wan't to create fat big jar every time and deploy it along with my application code. My application jar has size < 1 MB but dependencies > 20 MB
On my server i would run my application like:
java -cp core.lib.jar:core.jar myApp
I need to deploy only core.jar
to my server when i change application code and need to upload core.lib.jar
only when i change dependencies (this is very rare).
There's a lot of docs how to build fat jar with java sources but i want to exclude them and deliver it to the server independently.
There is two maven plugins for building fat jar: assembly and shade. I want to stick with shade.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.3</version>
<executions>
<execution>
<phase>none</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<excludes>
<exclude>core</exclude>
</excludes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
When i run mvn -pl core shade:shade
i get error: core: Failed to create shaded artifact, project main artifact does not exist
I thought that that option: core would exclude my sources from the artifact.
I set phase
to none
because i don't want to create fat jar when i want to run package
.
I would like to run mvn shade:shade
and have updated fat jar.
I'm not an expert in maven or its plugins, so any help is very appreciated :)
I needed to move this block under plugin / configuration
Used to be in
executions
block.Now i can run
mvn -pl core shade:shade
and have fat jar with dependencies only :)