32

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?

Tunaki
  • 132,869
  • 46
  • 340
  • 423
Daniella
  • 383
  • 1
  • 4
  • 12

3 Answers3

22

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.

oshai
  • 14,865
  • 26
  • 84
  • 140
1

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.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
  • not correct, unless you can explain why "terminology" leads to an extra plugin for gradle? – MushyPeas Jan 23 '18 at 12:08
  • @MushyPeas All three commands come from a plugin. "Uber Jar", "Fat Jar" and "Shadow Jar" are all the same concept, and none of the commands are provided by gradle. The question did not ask about the difference between a "Shadow Jar" and "Jar". – randers Jan 27 '18 at 18:27
-1

Uber Jar, Fat Jar and Shadow Jar are synonyms.

All three tasks do the same thing - you can choose the term you personally prefer the most.

randers
  • 5,031
  • 5
  • 37
  • 64
  • 1
    shadowJar is an extra plugin and not a synonym, it creates different jar then the jar tasks of Gradle. – MushyPeas Jan 23 '18 at 12:08