Wrong dependency handling when having dependencies to artifacts in different
versions
-------------------------------------------------------------------------------------
Key: MNG-2672
URL: http://jira.codehaus.org/browse/MNG-2672
Project: Maven 2
Issue Type: Bug
Components: Dependencies
Affects Versions: 2.0.4
Environment: Windows XP, JDK 1.4.2_12
Reporter: Fabian Christ
Hi,
let's take a look at the following situation. There is a project A which has
dependencies to B and C. Now both B and C have a dependency to D but in
different versions. B requires version D-1.0 and C version D-2.0.
Now in different situations is one time D-1.0 used and the next time D-2.0.
There is no chance to configure which version will be used. Notice the
restriction that I can't change the configured dependencies in B oder C - they
are given.Here is a list of different configurations and their results:
Base configuration:
A:
<dependency>
<groupId>org.test</groupId>
<artifactId>B</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.test</groupId>
<artifactId>C</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
B:
<dependency>
<groupId>org.test</groupId>
<artifactId>D</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
C:
<dependency>
<groupId>org.test</groupId>
<artifactId>D</artifactId>
<version>2.0</version>
<scope>compile</scope>
</dependency>
Debug:
[DEBUG] org.test:A:jar:1.0 (selected for null)
[DEBUG] org.test:B:jar:1.0-SNAPSHOT:compile (selected for compile)
[DEBUG] org.test:D:jar:1.0:compile (selected for compile)
[DEBUG] org.test:C:jar:1.0-SNAPSHOT:compile (selected for compile)
[DEBUG] org.test:D:jar:2.0:compile (removed - nearer found: 1.0)
=> so D-1.0.jar is used
Config 2:
Exclude artifact D from dependency on B in A:
<dependency>
<groupId>org.test</groupId>
<artifactId>B</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>org.test</groupId>
<artifactId>D</artifactId>
</exclusion>
</exclusions>
</dependency>
Debug:
[DEBUG] org.test:A:jar:1.0 (selected for null)
[DEBUG] org.test:B:jar:1.0-SNAPSHOT:compile (selected for compile)
[DEBUG] org.test:C:jar:1.0-SNAPSHOT:compile (selected for compile)
==> So D is never used (!) and so not on the classpath. Expected was to use
D-2.0. The exclude seems not to work correct here as it excludes the artifact
from the whole build.
Config 3:
No exclusions.
Change dependency of A to B-1.0-SNAPSHOT to B-1.0
Debug:
[DEBUG] org.test:A:jar:1.0 (selected for null)
[DEBUG] org.test:C:jar:1.0-SNAPSHOT:compile (selected for compile)
[DEBUG] org.test:D:jar:2.0:compile (selected for compile)
[DEBUG] org.test:B:jar:1.0:compile (selected for compile)
[DEBUG] org.test:D:jar:1.0:compile (removed - nearer found: 2.0)
==> so D-2.0.jar is used (!). Why is version 2.0 nearer now than 1.0? In the
base configuration above version 1.0 was nearer.
Config 4:
Change dependency of A to B-1.0-SNAPSHOT to B-1.0
Change dependency of A to C-1.0-SNAPSHOT to C-1.0
Debug:
[DEBUG] org.test:A:jar:1.0 (selected for null)
[DEBUG] org.test:C:jar:1.0:compile (selected for compile)
[DEBUG] org.test:D:jar:2.0:compile (selected for compile)
[DEBUG] org.test:B:jar:1.0:compile (selected for compile)
[DEBUG] org.test:D:jar:1.0:compile (removed - nearer found: 2.0)
==> so D-2.0.jar is used. Same result as with config 3.
So what would be the correct behavior here? At the moment it is not
configurable which version of D will be used during compile.
- Fabian
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira