Reputation: 1307
Have 3 projects. B depends on A, C depends on A and B. Both A and B depend on a package P of version 1, namely P1. Now C introduce another versoin of P, name it P2.
The denpendency tree may looks like
P1 P1
^ ^
| |
A <- B
^ ^
\ /
\ /
C -> P2
To avoid P confilict, I decide to prune P1, by modifying the pom.xml
in A and B. But weird
thing occurs: when I ran mvn eclipse:eclipse
in C, I found it still try to resolve the dependency of P1 !
I then carefully checked every project.
In A: Re-check the pom.xml -> NO dependency of P1 , it won't resolve P1 !
In B: Re-check the pom.xml -> NO dependency of P1 , it won't resolve P1 !
In C: Re-check the pom.xml -> NO dependency of P1 itself , but it DOES resolve P1!
|
| - Comment out dependency of A: Resolve P1 !
|
| - Comment out dependency of B: Resolve P1 !
|
| - Comment out dependency of both A & B: Won't resolve P1 !
Finally, I make sure that other packages of A , B and C that depend on do not
depend on P1(Actually, P1 is a small SDK with limited usage, I'm sure other
packages won't denpend on it)
So Here is the weird thing: From the check, it seems either A or B introduces P1, but in A and B respectively, I check and conclude that neither will introduce P1.
Anything wrong?
UPDATE
I finally figure out what is wrong: see the answer.
Upvotes: 0
Views: 157
Reputation: 1307
I finally figure out what is wrong:
From mvn dependency:tree
in C, I found that P1 exists in the sublevel of B.jar. So I went to B and ran mvn clean install
to update B.jar
, then went back to C, and now everything is OK.
I think this might be what happens:
Since B is project-depending on P1, so the old file in B.jar
that records the dependency of B(actually I extracted B.jar and found it is called META-INF/maven/path/to/B/pom.xml
) DOES NOT update as the pom.xml
in B
does. So when I ran mvn eclipse: eclipse
in C, it resovles B(C is also project-denpending on B, so it resolve B.jar ), which then resovles P1 by the dirty pom.xml in B.jar
, not the fresh pom.xml in B
). I think this is a poor design and ambiguous-bug-prone!
Upvotes: 1
Reputation: 3156
Try to run mvn dependency:tree on project C, you should see where P1 comes from.
Upvotes: 0