different dependencies for different classifiers in maven
I have a Maven artifact with a couple of dependencies. I want to publish the module built into a jar as normal, but I also want to publish a jar with its dependencies inside it using the maven shade plugin. This uber jar has a different classifier.
This all works fine, except if someone pulls in the uber jar using its classifier, they still get all the dependencies of the original, which they don't need.
How can I exclude certain dependencies based on the classifier? I have tried using profiles but I can't work out how to activate a profile based on the classifier of the artifact.
I know I could have the uber jar as a whole new artifact doing the exclusion itself, but that's a bit messy, I was hoping there was a better solution?
Try optional dependency. You have to declare all of your dependencies in the uber jar artifact's optional value to true.
Also, instead of using classifier, you might want to create another artifact. You can adapt this from mockito. See mockito-core vs mockito-all.