Uploaded image for project: 'Ivy'
  1. Ivy
  2. IVY-974

Dependencies don't inherit exclusions from dependencyManagement

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0-RC2
    • 2.1.0-RC1
    • Maven Compatibility
    • None

    Description

      In Maven 2, exclusions for a dependency can be given in the dependencyManagement element of an ancestor pom. These exclusions aren't correctly reproduced by Ivy.

      I have several projects here managed by Maven 2, and inheriting from a common ancestor. The pom of this ancestor includes the following fragment:

      <dependencyManagement>
      <dependencies>
      <dependency>
      <groupId>log4j</groupId><artifactId>log4j</artifactId><version>1.2.15</version>
      <exclusions>
      <exclusion><groupId>javax.mail</groupId><artifactId>mail</artifactId></exclusion>
      <exclusion><groupId>javax.jms</groupId><artifactId>jms</artifactId></exclusion>
      <exclusion><groupId>com.sun.jdmk</groupId><artifactId>jmxtools</artifactId></exclusion>
      <exclusion><groupId>com.sun.jmx</groupId><artifactId>jmxri</artifactId></exclusion>
      </exclusions>
      </dependency>
      </dependencies>
      </dependencyManagement>

      So in any inheriting project I can simply depend on log4j and get the correct version without the listed dependencies. This is important as some of these dependencies cannot be resolved from the main Maven repository. They are in fact optional, but not listed as such in the log4j pom. It is also Maven practice to list such exclusions in the common ancestor instead of repeating them in every module depending on log4j.

      Ivy 2 doesn't reproduce this kind of inherited exclusions. When I have an ivy project depending on one of my projects, the modules are not excluded, resulting in download errors for obscure packages. Looking at the ivy descriptors in cache I find the missing exclusions.

      To fix this, PomDependencyMgtElement in PomReader.java would have to learn to look out for exclusions. This information could than be used by PomModuleDescriptorBuilder. More precisely, addDependencyMgt would have to store it with the desciptor, and addDependency could then incorporate in its inheritance calculations. The whole setup with extra information, with keys calculated using getDependencyMgtExtraInfoKeyFor* and values restricted to strings, seems ill suited to express the structure of the dependency management information. I would prefer the ivy.xml to contain a m2:dependencyManagement element, and use Maven POM syntax within that element. I guess this approach would require larger modifications, though, so I doubt that's a good idea for 2.0 at least.

      Attachments

        1. parent_dependency_mgt_excludes.patch
          12 kB
          John Gibson
        2. parent_dependency_mgt_excludes_3.patch
          11 kB
          John Gibson
        3. parent_dependency_mgt_excludes_2.patch
          9 kB
          John Gibson

        Activity

          People

            maartenc Maarten Coene
            gagern Martin von Gagern
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: