Issue Details (XML | Word | Printable)

Key: MNG-1977
Type: New Feature New Feature
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Kees de Kooter
Votes: 95
Watchers: 66
Operations

If you were logged in you would be able to see more operations.
Maven 2 & 3

Global dependency exclusions

Created: 18/Jan/06 08:36 AM   Updated: 30/Dec/09 06:44 PM
Return to search
Component/s: POM
Affects Version/s: None
Fix Version/s: 3.1

Time Tracking:
Not Specified

Issue Links:
Duplicate
 
Related
 

Complexity: Intermediate


 Description  « Hide

I depend on some libraries, which in turn depend on something
(which in turn depend on something) that I don't want, because I declare
some other artifact in my pom.xml.

A concrete example: I don't want that the artifact "xerces" is imported in
my project because I declare to depend on "xercesImpl" which ships newer
libraries but with the same namespaces.

I guess I would need an "exclude transitive dependency at all", either
globally or from this and that artifact. I saw the <exclusions> tag, but it
forces me to be very verbose and have exact control on what is required by a
dependency.



Carlos Sanchez added a comment - 23/May/06 04:10 PM

From MNG-2031:

Transitive dependencies are cool, however, the limitations are very difficult to work around.

  • specification dependencies
  • jarjar dependencies (spring.jar includes all spring-xxx.jar, so no need to include them)
  • remove warning on relocations for transitive dependencies (it's always difficult to tell users: that's not an error, and we can not do anything)
  • poms on ibiblio are all in m2 and never change
  • exclusions for transitive deps can be overriden if manually included

One cool feature would be to allow disabling transitive dependencies in the following ways:

  • disable all transitive deps
  • enable transitive dependencies only for modules of the same project
  • enable transitive deps for specific groupIds
  • disable transitive deps for specific groupIds
  • have a tag/attribute to exclude all transitive deps for one dependency (instead of having list all exclusions)

Marc Portier added a comment - 11/Aug/06 04:50 AM

Adding another possibly featured way to configure:

  • disable all transitive deps for certain scopes

(e.g.: I'ld like transitive deps marked for 'runtime' and 'compile', but not for 'test')


Gilles T added a comment - 11/Aug/06 06:54 AM

The squeakiest tire get the oil first : That would be indeed a much wanted feature.

Gilles

Gilles Tabary


Stephan Niedermeier added a comment - 05/Jul/07 01:09 PM

Hi,

I'm wondering why this, in my eyes, important feature won't be fixed in 2.0x but in 2.1 (next year)? The initial request is more than one year old!

My project depends on some jars but NOT on their dependencies. Neither at compile nor at test or runtime. Therefore it makes no sense to download these dependecies at all.

With the current mechanism of using the <exclusions/> element within each dependency separately causes a lot of boilerplate configuration steps. In my case for over 30 dependencies!

I like the idea of having a global <exclusion/> element within <dependencyManagement/> or allowing wildcards for artifactId and groupId or intrdoucing an attribute transitive="false" on the <dependency/> element.

Please make this a higher prio, thanks!


Brian Fox added a comment - 05/Jul/07 01:52 PM

The main issue it that it can't be specified in the current pom model (4.0.0) and updates to the pom model require the next version aka 2.1.

There is a way to detect these creeping in, in dependency:analyze-dep-mgt and in the next enforcer release, there will be a rule that can fail the build when any excluded dependencies are found in the build.


Dan Allen added a comment - 30/Oct/07 02:37 PM

I don't know, I will miss all of the late nights and long weekends I spend analyzing the dependency tree trying to get rid of one stupid JAR file that causes the application not to run properly. What will I do with all my extra time? Wow, maybe I can actually DEVELOP something.


Wolfgang Nagele added a comment - 21/Nov/07 10:47 AM

I can just agree to others here, this is indeed a VERY important feature. It would ease the development a lot. As if you currently have such a bogus dependency you'll have to copy and paste every possible exclusion to every dependency. This is really ugly and costs a lot of time.


Clive Jevons added a comment - 07/Jul/08 09:34 AM

I'm currently also suffering from the lack of this feature and would be extremely grateful to see this one added
Cheers,
C


David Jencks added a comment - 13/Aug/08 05:54 PM

It seems to me that the original problem would be solved better by artifact substitution or aliasing rather than more exclusions. e.g if you want to use something reasonable such as slf4j to imitate commons logging usage you want to replace any dependency on commons-logging with one on jcl-over-slf4j. Similarly you might want to swap spec implementations, say to use the geronimo ones no matter which copies the original projects were built against, or use geronimo's activation implementation instead of sun's. This isn't quite the same as what osgi gives you but is quite powerful.


Kees de Kooter added a comment - 16/Aug/08 04:30 PM

You are right David, that would solve the original problem in an elegant way. Is this an existing feature I missed or should we submit a new jira issue for this?


Barry Kaplan added a comment - 11/Sep/08 04:09 PM

Aliasing would be nice. But I would also like to be able to specify that, for example, junit-3.8.1 should NEVER be downloaded and never be resolved as a dependency for my projects. I don't ever want junit-3.8.1 and junit-4.5 to both be in the same classpath.


Holger Hoffstätte added a comment - 11/Nov/08 06:05 PM

This just became a total showstopper with SpringSource effectively cloning the entire maven dependency set in their "enterprise" repo.
I know that's not maven's fault, but both global exclusions (e.g. as protections again known bad poms) and aliasing (to always substitute slf4j for clogging) would really fix a lot of problems that this has caused.


Brian Fox added a comment - 12/Nov/08 07:47 PM

That's a lovely development. If you use Nexus, you can control which artifacts come from a given repo so you can prevent the springsource repo from polluting your team. There's nothing that can be done inside maven for global exclusions until 3.0 since it requires a model change in the pom.


Pierre-Antoine Grégoire added a comment - 27/May/09 11:58 AM - edited

It's a sad thing that this will never be available for backports because the pom model cannot be changed..

This is a very much awaited feature. And though I like a lot tools of the like of Nexus (Artifactory is also very nice BTW), I think Maven should provide these mechanisms and that maybe 2.1 release was a bit rushed in this prospect.

Is there a timeframe for 3.0 already?

Why is this not planned for 2.2 for example?

Oh, and BTW: my simple wishes http://blog.zepag.org/2009/05/my-wishes-for-better-maven-2.html


Brian Fox added a comment - 27/May/09 12:15 PM

Pierre,

The pom format can't be changed until Maven 3.x. The alphas of 3.x are close by, but currently it's focused on 2.x compatibility with the new code and a process to handle pom model changes hasn't been built yet.


Neale added a comment - 12/Oct/09 12:23 PM

For those needing aliasing/substitution, there is a proposal at MNG-4391.

I note that David and Kees were suggesting this a year back.