1

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?

1 Answer 1

2

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.

3
  • (Snapshots are only included if the repo is configured thus.)
    – Ed Staub
    Commented Jul 28, 2011 at 23:53
  • @ED: yes, but if maven is configured to look in snapshot repository (for development) and the stable repository it does happen ... From development side of view i want some snapshot versions but not all, for some inhouse developed library i'll proably want the latest stable version.
    – mglauche
    Commented Jul 29, 2011 at 9:49
  • Thanks, you confirmed my worst expectations... Master-pom is not a suitable solution. I it's easier then to define version in the D's pom. The trick is that I don't want to define version manually.
    – Boris
    Commented Jul 30, 2011 at 11:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.