You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Mario Wirth <Wi...@bi-web.de> on 2010/05/05 10:10:50 UTC

Re: Problems with transitive dependencies in combination with version ranges

 Hello community,
I am wondering why I didn't get a response at all. Maybe not many maven users use this feature. 
Has anyone experiences with maven version ranges? Can you recommend using version ranges to affect the dependency resolution?

Thank you in advance.
Mario


-----Ursprüngliche Nachricht-----
Von: Mario Wirth 
Gesendet: Freitag, 23. April 2010 10:26
An: users@maven.apache.org
Betreff: Re: Problems with transitive dependencies in combination with version ranges

I would like to provide my example projects. Please find attached a zip file containing all necessary files.
Sorry, I've never used mailing lists before and I didn't know that I can simply attach files to share them with you.

I hope somebody can help. If this is a bug, I cannot use version ranges any longer. :-(

Greetings,
Mario

-----Ursprüngliche Nachricht-----
Von: Mario Wirth
Gesendet: Donnerstag, 22. April 2010 17:03
An: 'users@maven.apache.org'
Betreff: Problems with transitive dependencies in combination with version ranges

Hello,

I've got problems with transitive dependencies in combination with version ranges.
I use Maven Version 2.2.1

Example:

mvn dependency:tree ouput:
[INFO] X:X:jar:1.0.0
[INFO] +- Y:Y:jar:1.0.0:compile
[INFO] \- Z:Z:jar:1.0.0:compile
[INFO]    \- A:A:jar:1.0.0:compile

in other words, dependency graph is as follows: X -> Y -> Z 1.0.0 -> A

If I call mvn dependency:resolve, I get the following output:
[INFO] The following files have been resolved:
[INFO]    B:B:jar:1.0.0:compile
[INFO]    Y:Y:jar:1.0.0:compile
[INFO]    Z:Z:jar:1.0.0:compile

X -> Y -> Z 1.0.0 -> B

B is a wrong dependency. This is because of a version range, I've defined in the pom of X:

<groupId>X</groupId>
<artifactId>X</artifactId>
<name>X</name>
<version>1.0.0</version>

<dependencies>
	 <dependency>
		<groupId>Y</groupId>
		<artifactId>Y</artifactId>
		<version>1.0.0</version>
	</dependency>
	<dependency>
		<groupId>Z</groupId>
		<artifactId>Z</artifactId>
		<version>[1.0.0, 1.5.0]</version>    <-- error happens here
	</dependency>
</dependencies>

And the following lines represent the pom of Y:

<groupId>Y</groupId>
<artifactId>Y</artifactId>
<name>Y</name>
<version>1.0.0</version>

<dependencies>
	<dependency>
		<groupId>Z</groupId>
		<artifactId>Z</artifactId>
		<version>1.0.0</version>
	</dependency>
</dependencies>

What did happen? Y "whishes" to use Z in version 1.0.0. X does not matter if Z 1.0.0 or Z 1.5.0 is used.
In the resolved dependencies, maven selects the prefered version 1.0.0 of Z (because Y wants it).

BUT instead of pulling the suitable Dependency A of Z 1.0.0, maven is pulling the Dependency B of Z 1.5.0.
This can lead to horrible runtime exceptions (i.e ClassNotfoundExceptions)

If I replace the version range with a fix version (i.e. <version>1.5.0</version> or <version>1.0.0</version), the correct dependant of Z is pulled.
I guess this is a bug.
If so where and how can I create a Jira issue? If this is a feature, can anybody explain, please.
Maybe somebody can help.
Is it possible to attach files to this mailing list? I can offer a zip with my example projects, if needed.

Greetings
Mario Wirth

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org