Reputation: 25
I have a Maven project with one java file and that uses the Maven shade plugin to create an uber jar. My goal is to create an executable jar as small as possible. I decided to use the minimizeJar parameter in the plugin to make my jar smaller. Is the parameter only putting in the dependencies needed to run or the ones to compile or both?
Upvotes: 1
Views: 3024
Reputation: 61705
The answer is further up the page that you link to:
shade:shade
Full name: org.apache.maven.plugins:maven-shade-plugin:2.3:shade
Description: Mojo that performs shading delegating to the Shader component.
Attributes:
- Requires a Maven project to be executed.
- Requires dependency resolution of artifacts in scope: runtime.
- The goal is thread-safe and supports parallel builds.
- Binds by default to the lifecycle phase: package.
So the artifacts included will be runtime (and therefore compile time as well).
EDIT: For a full explanation of scopes, please see Introduction to the dependency mechanism - Dependency Scope.
In maven, when you do dependency resolution, it uses the notion of scopes - the three most important are (from that page):
So when you compile the sources under src/main/java, you will use dependencies with compile scope. When you run your application, you will use the dependencies with compile or runtime scope. When you compile your tests (under src/test/java), you will use compile and test scopes. When you run your tests with surefire, you will use the dependencies with the compile, test and runtime scopes.
This means that minimizeJar will contain the dependencies which are compile and runtime scope.
Upvotes: 1