This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
No, I've been reading, but haven't had time to respond. Exclusions are one way to do it, although I don't think you have the syntax right. You have to specify the <exclusion> inside the <dependency>. At least, that's what the online docs say--it's possible a top-level <exclusion> tag exists and they just haven't updated the docs.
Another (and apparently better) way to do it is by specifying the transitive dependency as optional. In your example, the POM for Project A should include:
Then when project B adds Project A as a dependency, it won't also grab "x.jar".
You also may be able to use the "provided" scope to accomplish this, depending on what you're doing.
Exclusions are one way to do it, although I don't think you have the syntax right.
yes, you're right. was a quick snippet code copy/paste error.
Another (and apparently better) way to do it is by specifying the transitive dependency as optional.
ahh, i see. so the optional flag seems the opposite of the exclusions tag. i tell the dependency itself not to open up its dependencies to the outside world. with the exclusion tag it is the other way round, the instance which includes a dependency restricts the transitive inclusion.
never the less if maven's future request excludesAll tag gets implemented it is also quite handy, because i only have to place the exclude to the one inlcuded dependent-project. with the optional flag i would need to set the optional flag to all included dependencies.
but until this feature gets implemented in maven 2.1 i obviously will use the optional flag. well, let's see maybe i can help the development crew to develop this feature... [ June 28, 2007: Message edited by: manuel aldana ]