Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-4263

Dependencies resolution & the order in the declaration

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 2.0.8
    • Fix Version/s: None
    • Component/s: Dependencies
    • Labels:
      None
    • Environment:
      Maven version: 2.0.8
      Java version: 1.5.0_15
      OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"

      Description

      Hi, I've got som trouble with Maven resolution.

      I read (here : http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html ):

      Dependency mediation - this determines what version of a dependency will be used when multiple versions of an artifact are encountered. Currently, Maven 2.0 only supports using the "nearest definition" which means that it will use the version of the closest dependency to your project in the tree of dependencies. You can always guarantee a version by declaring it explicitly in your project's POM. Note that if two dependency versions are at the same depth in the dependency tree, until Maven 2.0.4 it was not defined which one would win, but since Maven 2.0.5 it's the order in the declaration that counts: the first declaration wins.

      So what does 'the order in the declaration' mean ? if it is the pom declaration i ve got a probleme.

      I ve got 3 projects :

      project-test-a

      <?xml version="1.0" encoding="UTF-8"?>
      <project>
      	<modelVersion>4.0.0</modelVersion>
      	<groupId>test</groupId>
      	<artifactId>project-test-a</artifactId>
      	<version>0.0.1-SNAPSHOT</version>
      	<description></description>
      	<dependencies>
      		<dependency>
      			<groupId>log4j</groupId>
      			<artifactId>log4j</artifactId>
      			<version>1.2.8</version>
      		</dependency>
      	</dependencies>
      </project>
      

      project-test-b

      <?xml version="1.0" encoding="UTF-8"?>
      <project>
      	<modelVersion>4.0.0</modelVersion>
      	<groupId>test</groupId>
      	<artifactId>project-test-b</artifactId>
      	<version>0.0.1-SNAPSHOT</version>
      	<description></description>
      	<dependencies>
      		<dependency>
      			<groupId>log4j</groupId>
      			<artifactId>log4j</artifactId>
      			<version>1.2.7</version>
      		</dependency>
      	</dependencies>
      </project>
      

      project-test, (use project-test-a and project-test-b)

      	<dependencies>
      		<dependency>
      			<groupId>test</groupId>
      			<artifactId>project-test-a</artifactId>
      			<version>0.0.1-SNAPSHOT</version>
      		</dependency>
      		<dependency>
      			<groupId>test</groupId>
      			<artifactId>project-test-b</artifactId>
      			<version>0.0.1-SNAPSHOT</version>
      		</dependency>
      	</dependencies>
      

      So the "nearest definition" is not usefull here because they has got the same depth.
      So i use the 'the order in the declaration' and for me, the project 'project-test-a' is above the 'b'
      So the top project (project-test) must use the LOG4J:1.2.8 no ????

      D:\CNT2\wk\wkTest\project-test>mvn dependency:tree
      [INFO] Scanning for projects...
      [INFO] Searching repository for plugin with prefix: 'dependency'.
      [INFO] ------------------------------------------------------------------------
      [INFO] Building Unnamed - test:project-test:jar:0.0.1-SNAPSHOT
      [INFO]    task-segment: [dependency:tree]
      [INFO] ------------------------------------------------------------------------
      [INFO] snapshot test:project-test-b:0.0.1-SNAPSHOT: checking for updates from inhouse_snapshots
      [INFO] snapshot test:project-test-a:0.0.1-SNAPSHOT: checking for updates from inhouse_snapshots
      [INFO] [dependency:tree]
      [INFO] test:project-test:jar:0.0.1-SNAPSHOT
      [INFO] +- test:project-test-b:jar:0.0.1-SNAPSHOT:compile
      [INFO] |  \- log4j:log4j:jar:1.2.7:compile
      [INFO] \- test:project-test-a:jar:0.0.1-SNAPSHOT:compile
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD SUCCESSFUL
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 6 seconds
      [INFO] Finished at: Tue Jul 28 15:23:22 CEST 2009
      [INFO] Final Memory: 8M/17M
      [INFO] ------------------------------------------------------------------------
      

      Where is the problemes ???

      Thx

        Attachments

        1. project-test.zip
          6 kB
          Arnaud

          Issue Links

            Activity

              People

              • Assignee:
                bentmann Benjamin Bentmann
                Reporter:
                fdk Arnaud
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: