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?

Answers


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.


Need Your Help

Haskell readFile: Couldn't match expected type ‘[String]’ with actual type ‘IO String’

string haskell io ghc ghci

I am trying to read a file into a function to calculate the frequencies of characters in a file. So I am trying the following:

JQuery validation plugin and custom rule

jquery jquery-validate

I'm using the jquery.validation plugin in my web app.