Is it possible to rename a maven jar-with-dependencies?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
Yes, you can rename a Maven fat JAR, but the right way depends on which plugin is producing it. If you are using the Assembly Plugin's built-in jar-with-dependencies descriptor, the default classifier gets appended automatically unless you change the plugin configuration or switch to a more flexible plugin such as Shade.
Understand Why the Default Name Appears
With the Maven Assembly Plugin, the built-in jar-with-dependencies descriptor usually produces a file name like this:
That suffix comes from the assembly identifier. It is not random, and Maven is not ignoring your artifact name. The plugin is attaching a classified artifact to the build output.
Rename It with the Assembly Plugin
If you want the final file to avoid the -jar-with-dependencies suffix, configure the assembly plugin not to append the assembly ID.
With that setup, the output becomes my-runner.jar instead of the longer classified name.
Know the Difference Between finalName and Classifiers
Two settings are easy to confuse:
- '
finalNamecontrols the base file name' - '
appendAssemblyIdcontrols whether the assembly ID such asjar-with-dependenciesis appended'
Setting only finalName is often not enough if the classifier is still being appended. That is why people think Maven is "ignoring" the rename.
Consider the Shade Plugin for Executable Fat JARs
If your real goal is a single executable JAR for runtime use, the Maven Shade Plugin is often the better tool. It handles dependency merging, relocation, and executable packaging more cleanly than assembly in many projects.
In many modern Java projects, Shade is the more maintainable answer if you are building an application rather than a distribution archive.
Verify the Output You Actually Need
Sometimes teams want two artifacts:
- the normal project JAR for repository publishing
- a separate executable fat JAR for deployment
If that is your situation, do not blindly replace the main artifact unless you are sure downstream tooling expects that behavior. Artifact naming is tied to repository publishing, deployment scripts, and CI artifacts, so a rename can have operational side effects.
Prefer Predictable Naming in CI
If the fat JAR is consumed by deployment automation, keep the final name stable across builds unless the version is intentionally part of the deployment contract. Predictable artifact names reduce shell-script complexity and make release pipelines easier to reason about.
Common Pitfalls
- Setting
finalNameand expecting it to remove thejar-with-dependenciesclassifier automatically. - Using the Assembly Plugin when the Shade Plugin is a better fit for executable fat JARs.
- Replacing the main artifact accidentally when downstream tooling still expects the original one.
- Forgetting to verify manifest configuration for the main class after changing packaging plugins.
- Treating file naming as cosmetic when CI and deployment scripts may depend on it.
Summary
- Yes, you can rename a Maven
jar-with-dependenciesoutput. - With the Assembly Plugin, the critical setting is often
appendAssemblyId=false. - '
finalNamechanges the base name, but classifiers still matter.' - The Shade Plugin is often a better choice for runnable fat JARs.
- Always confirm how the renamed artifact affects publishing and deployment workflows.
Related reading
- Is it possible to set a different specification per cache using caffeine in spring boot?
- Is it possible to set private property via reflection?
- Is it possible to use Java 8 for Android development?
- Is it possible to use Java 8 for Android development?
- Is it possible with Spring Boot to serve up JSPs with a JAR packaging?
- Is it safe to get values from a java.util.HashMap from multiple threads no modification?
- Is it safe to get values from a java.util.HashMap from multiple threads no modification?
- Is it worth to use slf4j with log4j2

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.