Uber JAR, in short, is a JAR containing everything.
Normally in Maven, we rely on dependency management. An artifact contains only the classes/resources of itself. Maven will be responsible to find out all artifacts (JARs etc) that the project depending on when the project is built.
An uber-jar is something that takes all dependencies, and extracts the content of the dependencies and puts them with the classes/resources of the project itself, in one big JAR. By having such an uber-jar, it is easy for execution, because you will need only one big JAR instead of tons of small JARs to run your app. It also eases distribution in some cases.
Just a side-note: avoid using uber-jar as a Maven dependency, as it is ruining the dependency resolution feature of Maven. Normally we create an uber-jar only for the final artifact for actual deployment or for manual distribution, but not for putting to Maven repository.
Update: I have just discovered I haven't answered one part of the question : "What's the point of renaming the packages of the dependencies?". Here are some brief updates that will hopefully help people having similar questions.
Creating an uber-jar for ease of deployment is one use case of the shade plugin. There are also other common use cases which involve package renaming.
For example, I am developing Foo
library, which depends on a specific version (e.g. 1.0) of Bar
library. Assuming I cannot make use of other version of Bar
lib (because API change, or other technical issues, etc). If I simply declare Bar:1.0
as Foo
's dependency in Maven, it is possible to fall into a problem: A Qux
project is depending on Foo
, and also Bar:2.0
(and it cannot use Bar:1.0
because Qux
needs to use new feature in Bar:2.0
). Here is the dilemma: should Qux
use Bar:1.0
(which Qux
's code will not work) or Bar:2.0
(which Foo
's code will not work)?
In order to solve this problem, developer of Foo
can choose to use shade plugin to rename its usage of Bar
, so that all classes in Bar:1.0
jar are embedded in Foo
jar, and the package of the embedded Bar
classes is changed from com.bar
to com.foo.bar
. By doing so, Qux
can safely depends on Bar:2.0
because now Foo
is no longer depending on Bar
, and it is using its own copy of the "altered" Bar
located in another package.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…