Maven
  1. Maven
  2. MNG-4982

[regression] Cycle between transitive dependencies causes bad effective dependency scope

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.2
    • Fix Version/s: 3.0.3
    • Component/s: Dependencies
    • Labels:
      None
    • Environment:
    • Complexity:
      Intermediate
    • Number of attachments :
      1

      Description

      I'm getting different transitive dependency scope resolution when building with Maven 3. Transitive dependencies from a provided scope should be resolved to provided according to the docs, but it is resolving to compile as shown below. When building with Maven 2 it works correctly.

      I tried to isolate the problem with a simpler scenario, but could only reproduce using the org.apache.xmlgraphics:fop:jar:1.0 dependency.

      Maven 3 dependency output snippet:

      [DEBUG] test:a:jar:1
      [DEBUG]    test:a-deps:pom:1:provided
      [DEBUG]       org.apache.xmlgraphics:fop:jar:1.0:provided
      [DEBUG]          org.apache.xmlgraphics:xmlgraphics-commons:jar:1.4:provided
      [DEBUG]          org.apache.xmlgraphics:batik-svg-dom:jar:1.7:compile
      [DEBUG]             org.apache.xmlgraphics:batik-anim:jar:1.7:compile
      [DEBUG]             org.apache.xmlgraphics:batik-css:jar:1.7:compile
      [DEBUG]             org.apache.xmlgraphics:batik-dom:jar:1.7:compile
      [DEBUG]             org.apache.xmlgraphics:batik-parser:jar:1.7:compile
      [DEBUG]             org.apache.xmlgraphics:batik-util:jar:1.7:compile
      [DEBUG]             xml-apis:xml-apis:jar:1.3.04:compile
      [DEBUG]             xml-apis:xml-apis-ext:jar:1.3.04:compile
      [DEBUG]          org.apache.xmlgraphics:batik-bridge:jar:1.7:provided
      [DEBUG]             org.apache.xmlgraphics:batik-script:jar:1.7:provided
      [DEBUG]                org.apache.xmlgraphics:batik-js:jar:1.7:provided
      [DEBUG]             org.apache.xmlgraphics:batik-xml:jar:1.7:compile
      [DEBUG]             xalan:xalan:jar:2.6.0:compile
      [DEBUG]          org.apache.xmlgraphics:batik-awt-util:jar:1.7:compile
      [DEBUG]          org.apache.xmlgraphics:batik-gvt:jar:1.7:provided
      [DEBUG]          org.apache.xmlgraphics:batik-transcoder:jar:1.7:provided
      [DEBUG]             org.apache.xmlgraphics:batik-svggen:jar:1.7:provided
      [DEBUG]          org.apache.xmlgraphics:batik-extension:jar:1.7:provided
      [DEBUG]          org.apache.xmlgraphics:batik-ext:jar:1.7:compile
      [DEBUG]          commons-logging:commons-logging:jar:1.0.4:provided
      [DEBUG]          commons-io:commons-io:jar:1.3.1:provided
      [DEBUG]          org.apache.avalon.framework:avalon-framework-api:jar:4.3.1:provided
      [DEBUG]          org.apache.avalon.framework:avalon-framework-impl:jar:4.3.1:provided
      

      Maven 2 dependency output:

      [DEBUG] test:a:jar:1 (selected for null)
      [DEBUG]   test:a-deps:pom:1:provided (selected for provided)
      [DEBUG]     org.apache.xmlgraphics:fop:jar:1.0:provided (selected for provided)
      [DEBUG]       org.apache.xmlgraphics:xmlgraphics-commons:jar:1.4:provided (selected for provided)
      [DEBUG]         commons-io:commons-io:jar:1.3.1:provided (selected for provided)
      [DEBUG]         commons-logging:commons-logging:jar:1.0.4:provided (selected for provided)
      [DEBUG]       org.apache.xmlgraphics:batik-svg-dom:jar:1.7:provided (selected for provided)
      [DEBUG]         org.apache.xmlgraphics:batik-svg-dom:jar:1.7:provided (removed - causes a cycle in the graph)
      [DEBUG]         org.apache.xmlgraphics:batik-anim:jar:1.7:provided (selected for provided)
      [DEBUG]           org.apache.xmlgraphics:batik-awt-util:jar:1.7:provided (selected for provided)
      [DEBUG]             org.apache.xmlgraphics:batik-util:jar:1.7:provided (selected for provided)
      [DEBUG]           org.apache.xmlgraphics:batik-dom:jar:1.7:provided (selected for provided)
      [DEBUG]             org.apache.xmlgraphics:batik-css:jar:1.7:provided (selected for provided)
      [DEBUG]               org.apache.xmlgraphics:batik-ext:jar:1.7:provided (selected for provided)
      [DEBUG]                 xml-apis:xml-apis:jar:1.3.04:provided (selected for provided)
      [DEBUG]               xml-apis:xml-apis:jar:1.3.04:provided (selected for provided)
      [DEBUG]               xml-apis:xml-apis-ext:jar:1.3.04:provided (selected for provided)
      [DEBUG]             org.apache.xmlgraphics:batik-ext:jar:1.7:provided (selected for provided)
      [DEBUG]             org.apache.xmlgraphics:batik-xml:jar:1.7:provided (selected for provided)
      [DEBUG]             xalan:xalan:jar:2.6.0:provided (selected for provided)
      [DEBUG] While downloading xml-apis:xml-apis:2.0.2
        This artifact has been relocated to xml-apis:xml-apis:1.0.b2.
      
      
      [DEBUG]               xml-apis:xml-apis:jar:1.0.b2:provided (removed - nearer found: 1.3.04)
      [DEBUG]             xml-apis:xml-apis:jar:1.3.04:provided (selected for provided)
      [DEBUG]             xml-apis:xml-apis-ext:jar:1.3.04:provided (selected for provided)
      [DEBUG]           org.apache.xmlgraphics:batik-ext:jar:1.7:provided (selected for provided)
      [DEBUG]           org.apache.xmlgraphics:batik-parser:jar:1.7:provided (selected for provided)
      [DEBUG]         org.apache.xmlgraphics:batik-awt-util:jar:1.7:provided (selected for provided)
      [DEBUG]           org.apache.xmlgraphics:batik-util:jar:1.7:provided (selected for provided)
      [DEBUG]         org.apache.xmlgraphics:batik-css:jar:1.7:provided (selected for provided)
      [DEBUG]           xml-apis:xml-apis:jar:1.3.04:provided (selected for provided)
      [DEBUG]           xml-apis:xml-apis-ext:jar:1.3.04:provided (selected for provided)
      [DEBUG]         org.apache.xmlgraphics:batik-dom:jar:1.7:provided (selected for provided)
      [DEBUG]           org.apache.xmlgraphics:batik-xml:jar:1.7:provided (selected for provided)
      [DEBUG]           xalan:xalan:jar:2.6.0:provided (selected for provided)
      [DEBUG] While downloading xml-apis:xml-apis:2.0.2
        This artifact has been relocated to xml-apis:xml-apis:1.0.b2.
      
      
      [DEBUG]             xml-apis:xml-apis:jar:1.0.b2:provided (removed - nearer found: 1.3.04)
      [DEBUG]         org.apache.xmlgraphics:batik-ext:jar:1.7:provided (selected for provided)
      [DEBUG]         org.apache.xmlgraphics:batik-parser:jar:1.7:provided (selected for provided)
      [DEBUG]         org.apache.xmlgraphics:batik-util:jar:1.7:provided (selected for provided)
      [DEBUG]         xml-apis:xml-apis:jar:1.3.04:provided (selected for provided)
      [DEBUG]         xml-apis:xml-apis-ext:jar:1.3.04:provided (selected for provided)
      [DEBUG]       org.apache.xmlgraphics:batik-bridge:jar:1.7:provided (selected for provided)
      [DEBUG]         org.apache.xmlgraphics:batik-bridge:jar:1.7:provided (removed - causes a cycle in the graph)
      [DEBUG]         org.apache.xmlgraphics:batik-gvt:jar:1.7:provided (selected for provided)
      [DEBUG]         org.apache.xmlgraphics:batik-bridge:jar:1.7:provided (removed - causes a cycle in the graph)
      [DEBUG]         org.apache.xmlgraphics:batik-script:jar:1.7:provided (selected for provided)
      [DEBUG]         org.apache.xmlgraphics:batik-xml:jar:1.7:provided (selected for provided)
      [DEBUG]         xalan:xalan:jar:2.6.0:provided (selected for provided)
      [DEBUG] While downloading xml-apis:xml-apis:2.0.2
        This artifact has been relocated to xml-apis:xml-apis:1.0.b2.
      
      
      [DEBUG]           xml-apis:xml-apis:jar:1.0.b2:provided (removed - nearer found: 1.3.04)
      [DEBUG]       org.apache.xmlgraphics:batik-awt-util:jar:1.7:provided (selected for provided)
      [DEBUG]       org.apache.xmlgraphics:batik-gvt:jar:1.7:provided (selected for provided)
      [DEBUG]         org.apache.xmlgraphics:batik-gvt:jar:1.7:provided (removed - causes a cycle in the graph)
      [DEBUG]       org.apache.xmlgraphics:batik-transcoder:jar:1.7:provided (selected for provided)
      [DEBUG]         org.apache.xmlgraphics:batik-svggen:jar:1.7:provided (selected for provided)
      [DEBUG]       org.apache.xmlgraphics:batik-extension:jar:1.7:provided (selected for provided)
      [DEBUG]       org.apache.xmlgraphics:batik-ext:jar:1.7:provided (selected for provided)
      [DEBUG]       commons-logging:commons-logging:jar:1.0.4:provided (selected for provided)
      [DEBUG]       commons-io:commons-io:jar:1.3.1:provided (selected for provided)
      [DEBUG] Retrieving parent-POM: org.apache.avalon:avalon-framework:pom:1 for project: org.apache.avalon.framework:avalon-framework-api:jar:4.3.1 from the repository.
      [DEBUG] Retrieving parent-POM: org.apache.excalibur:excalibur:pom:1 for project: org.apache.avalon:avalon-framework:pom:1 from the repository.
      [DEBUG]       org.apache.avalon.framework:avalon-framework-api:jar:4.3.1:provided (selected for provided)
      [DEBUG]       org.apache.avalon.framework:avalon-framework-impl:jar:4.3.1:provided (selected for provided)
      

      I'm attaching a sample project that allows to reproduce the problem and logs.
      I've run: mvn -X clean package

        Issue Links

          Activity

          Hide
          Kari J. Niemi added a comment -

          In both dependency tree logs org.apache.xmlgraphics:fop:jar:1.0 has the scope "provided". Hmmm... or is there something wrong with my eyes?

          Show
          Kari J. Niemi added a comment - In both dependency tree logs org.apache.xmlgraphics:fop:jar:1.0 has the scope "provided". Hmmm... or is there something wrong with my eyes?
          Hide
          Renato Garcia added a comment -

          Correct, but the problem is with the transitive deps of fop. Take a look at org.apache.xmlgraphics:batik-svg-dom for instance.

          Show
          Renato Garcia added a comment - Correct, but the problem is with the transitive deps of fop. Take a look at org.apache.xmlgraphics:batik-svg-dom for instance.
          Hide
          Benjamin Bentmann added a comment -

          Trigger for the bug is a cyclic dependency between batik-svg-dom:1.7 and batik-anim:1.7. Breaking this cycle via an explicit exclusion in project a provides a workaround:

            <dependencyManagement>
              <dependencies>
                <dependency>
                  <groupId>org.apache.xmlgraphics</groupId>
                  <artifactId>batik-anim</artifactId>
                  <version>1.7</version>
                  <exclusions>
                    <exclusion>
                      <groupId>org.apache.xmlgraphics</groupId>
                      <artifactId>batik-svg-dom</artifactId>
                    </exclusion>
                  </exclusions>
                </dependency>
              </dependencies>
            </dependencyManagement>
          
          Show
          Benjamin Bentmann added a comment - Trigger for the bug is a cyclic dependency between batik-svg-dom:1.7 and batik-anim:1.7 . Breaking this cycle via an explicit exclusion in project a provides a workaround: <dependencyManagement> <dependencies> <dependency> <groupId> org.apache.xmlgraphics </groupId> <artifactId> batik-anim </artifactId> <version> 1.7 </version> <exclusions> <exclusion> <groupId> org.apache.xmlgraphics </groupId> <artifactId> batik-svg-dom </artifactId> </exclusion> </exclusions> </dependency> </dependencies> </dependencyManagement>
          Hide
          Benjamin Bentmann added a comment -

          Fixed in r1074131.

          Show
          Benjamin Bentmann added a comment - Fixed in r1074131 .

            People

            • Assignee:
              Benjamin Bentmann
              Reporter:
              Renato Garcia
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: