Maven Ant Tasks
  1. Maven Ant Tasks
  2. MANTTASKS-7

dependencies ant task does not handle scoped transitive dependencies correctly

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0.6
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows XP, Java 1.5.0_08-b03, Ant 1.6.5, Maven 2.0.4
    • Number of attachments :
      0

      Description

      The ant <dependencies> task resolves transitive dependencies incorrectly if they're included in different scopes. Here's an example:

      [dependencies section of pom.xml for project A]
      ...
      <dependencies>
      <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.13</version>
      </dependency>
      </dependencies>
      ...

      [dependencies section of pom.xml for project B]
      ...
      <dependencies>
      <dependency>
      <groupId>my-company</groupId>
      <artifactId>project-A</artifactId>
      <version>1.0-SNAPSHOT</version>
      <scope>test</scope>
      </dependency>
      <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.13</version>
      </dependency>
      <dependency>
      <groupId>commons-lang</groupId>
      <artifactId>commons-lang</artifactId>
      <version>2.1</version>
      </dependency>
      </dependencies>
      ...

      [dependencies section of pom.xml for project C]
      ...
      <dependencies>
      <dependency>
      <groupId>my-company</groupId>
      <artifactId>project-B</artifactId>
      <version>1.0-SNAPSHOT</version>
      </dependency>
      </dependencies>
      ...

      When I use the <dependencies> task to build a "compile"-scope classpath for project B everything is OK:
      <mvn:dependencies pathId="compile.classpath" useScope="compile">
      <pom refid="maven.pom" />
      </mvn:dependencies>
      – gives –
      \.m2\repository\commons-lang\commons-lang\2.1\commons-lang-2.1.jar
      \.m2\repository\log4j\log4j\1.2.13\log4j-1.2.13.jar

      But when I use the same task to build a "compile"-scope classpath for project C, log4j goes missing:
      <mvn:dependencies pathId="compile.classpath" useScope="compile">
      <pom refid="maven.pom" />
      </mvn:dependencies>
      – gives –
      \.m2\repository\nl\forcare\common\1.0-SNAPSHOT\common-1.0-SNAPSHOT.jar
      \.m2\repository\commons-lang\commons-lang\2.1\commons-lang-2.1.jar

      I think that that log4j is filtered, because project A is only included in test scope, regardless of log4j also being present in project B. If I use the mvn executable itself to run a compile instead of the ant tasks, then there is no problem and log4j appears on the compile classpath. It seems that the ant tasks have a different mechanism of resolving dependencies than the mvn executable.

        Issue Links

          Activity

          Hide
          Herve Boutemy added a comment -

          working on MNG-2859, I found that Maven Ant Tasks 2.0.4 seem to be using Maven 2.0.2 internals, which would explain our feeling "It seems that the ant tasks have a different mechanism of resolving dependencies than the mvn executable."

          I attached a Maven Ant Tasks build done with 2.0.5 dependancies: can you check if it works better for you ?

          Show
          Herve Boutemy added a comment - working on MNG-2859 , I found that Maven Ant Tasks 2.0.4 seem to be using Maven 2.0.2 internals, which would explain our feeling "It seems that the ant tasks have a different mechanism of resolving dependencies than the mvn executable." I attached a Maven Ant Tasks build done with 2.0.5 dependancies: can you check if it works better for you ?
          Hide
          Herve Boutemy added a comment -

          I had the same case here: maven-artifact-ant-2.0.5-SNAPSHOT-dep.jar from MNG-2859 solved the problem

          Show
          Herve Boutemy added a comment - I had the same case here: maven-artifact-ant-2.0.5-SNAPSHOT-dep.jar from MNG-2859 solved the problem
          Hide
          Jason van Zyl added a comment -

          Fixed with the 2.0.6 release.

          Show
          Jason van Zyl added a comment - Fixed with the 2.0.6 release.

            People

            • Assignee:
              Unassigned
              Reporter:
              Rick Riemer
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: