Including libraries, avoiding conflicts for the code your code uses.
Specific example:
I am writing a library to provide specific functionality. When I write my library, and not reinvent the wheel, I want to use Apache Commons (i.e. StringUtils, etc.). Unfortunately, if I include this library with mine, either as a separate jar or built into my own jar (build-with-dependencies), I force Apache Commons on everyone who uses my library ... plus I force the version that i used on them.
Question:
Is there a way to create a library / jar in Java that depends on a third party library without forcing that library (or worse, a version of that library) to those using your library?
source to share
If you intend to distribute a binary jar through Maven, you shouldn't worry too much about "forcing" dependence on anyone using the jar. Anyone using Maven is fully used to migrate transitive dependencies. Maven has a lot of whistling codes for sorting version conflicts.
If you are ultra paranoid about this, you can use the shade plugin to generate uber-jar with dependencies and rename all dependency packages: http://maven.apache.org/plugins/maven-shade-plugin/examples/class-relocation. html , but this is not required.
source to share