maven dependency problem when jenkins builds the p

2019-07-29 01:56发布

问题:

I have two maven projects, let's say A and B, merely A requires B, reverse is not true. There is no problem when I package A from eclipse. In the "pom.xml" of the project A has a dependency node on B. In jenkins, I configured the project B by adding three goals, which are "clean package install". Therefore, whenever the build of B finishes, it must be exist the archive file of the B in my local maven repository that there is(I checked it). On the other hand, when I build the project A, I got lots of compilation errors "cannot find symbol x". What might be the problem, any ideas?

Thanks in advance.

回答1:

Just to make sure: You looked into ~jenkins/.m2/repository/, yes?

Note that install always includes package, so clean install is enough.

But the problem is elsewhere.

  1. Check that the versions are the same. Use an exact version number in the dependency of A, not a version range to make sure what it picks up (otherwise, Maven might find a "more suitable" version).

  2. If the dependency wasn't there, Maven wouldn't start the compiler (because building the classpath would fail). So the problem is not the JAR file but the content. Make sure that B's JAR file really contains what you expect (jar tvf is your friend).

  3. Delete the repository on the Jenkins server to make sure there is no old junk in there.