Boris
Boris

Reputation: 1126

Maven: how to use the latest version from dependencies (not from all repository)

Suppose I have the following artifacts. I will omit groups for simplicity.

A:1.0
A:2.0
A:3.0
B:1.0 depends on A:1.0
C:1.0 depends on A:2.0
D:1.0 depends on B:1.0, C:1.0

I want D to use the latest version of A that is inherited from it's dependencies (not from repository). In this case it is 2.0.

How can I make this with Maven 2 or Maven 3?

Upvotes: 1

Views: 553

Answers (1)

mglauche
mglauche

Reputation: 3394

Usually maven takes the version which is closest to the root, in your case maven(2/3) should pick up A:2.0 automaticly (as they are equally far away)

Another option would be to use version ranges, like A:[2.0,] but this would take the latest from the repository. (and it would include SNAPSHOT versions, which makes the current maven3 quite unuseable for version ranges)

The (IMHO) correct way would be to use a master-pom with a dependency-management tag and declare that A:2.0 should be used for all subprojects.

Upvotes: 2

Related Questions