I'm trying to understand when should I use which. I understand that they all assemble all the dependent classes, but how are they different from each other?
Shadow is a plugin that packages an application into an executable fat jar file if the current file is outdated. Tutorials → Working with JAR files → Fat JAR files. The task shadowJar (e.g., running the command gradlew shadowJar or gradlew clean shadowJar ) creates the JAR file in the build/libs folder.
An uber-JAR—also known as a fat JAR or JAR with dependencies—is a JAR file that contains not only a Java program, but embeds its dependencies as well. This means that the JAR functions as an “all-in-one” distribution of the software, without needing any other Java code.
Shadow is a Gradle plugin for combining a project's dependency classes and resources into a single output Jar. The combined Jar is often referred to a fat-jar or uber-jar.
The terms are sometimes used interchangeably, but usually refers to:
Fat jar (also named Uber jar) - used to describe a jar that has all classes from dependent jars zipped directly inside it in the correct directory structure, and not in other jars. There is a good explanation here.
Shaded jar (or shaded classes) - usually refers to a process of changing classes bytecode to change packages names of the classes, and also modify were it is used in the jar. It is used to link classes to a specific version of other classes and avoid versions collisions. It can be created by Maven Shade Plugin. Shaded jar do not necessary contain all the dependencies needed.
The gradle shadow plugin can generate both fat jars and shaded jars, and same for the maven shaded plugin. I guess that is why people mix those terms.
Note: I have seen cases that refers to fat jar as a jar contains dependencies as a packed jars inside it.
There is no difference whatsoever. These terms are all synonyms of each other.
The term "uber-jar" may be more commonly used in documentations (take the maven-shade-plugin
documentation for example) but "fat-jar" is also widely used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With