I'm working on a project which has an "optional" transitive
dependency.  That is: we depend on someone else's artifact (let's call
it A), which itself depends *in some circumstances* on a third
artifact (from a third source) which I'll call "B".  That is:  if you
never trigger a certain feature of A then it doesn't really need B.  A
expresses this by making B a dependency with <scope>provided</scope>.

I feel that this is an abuse of the dependency mechanism, and that
optional dependencies should not be declared to Maven as dependencies
at all.  I think that A should use Class.forName to probe for B and
(if not found) gracefully explain why it cannot perform the requested
function.  What do you think?

The feature in question is decryption of a file, which is triggered
when A recognizes an encrypted file, and that is out of our control.
Decryption requires key material, and in our application there is no
reasonable opportunity to provide it, so we can't actually make use of
the decryption function.  We are thus faced with a choice: declare a
transitive dependency as if it were a direct dependency, to support an
unusable feature, and leave notes all over our POMs to explain why
dependency:analyze is wrong and you should not remove this dependency;
or keep explaining to people why they get NoClassDefFoundError when
processing some of their files.

-- 
Mark H. Wood
Lead Technology Analyst

University Library
Indiana University - Purdue University Indianapolis
755 W. Michigan Street
Indianapolis, IN 46202
317-274-0749
www.ulib.iupui.edu

Attachment: signature.asc
Description: Digital signature

Reply via email to