Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Propagating dependency version to grandchild module in Maven

Tags:

maven

i have a project with the following structure:

Master (pom)
|_Project A (pom)
  |_Project A1 (jar)

Project Master manages the version of dependency xyz. The project A1 uses this dependency, but the build is broken, it complains about dependency xyz version, that its missing. Any ideas on how to propagate that version? Any help appreciated.

like image 775
user1005427 Avatar asked Oct 18 '25 10:10

user1005427


2 Answers

A very old question, but I still find it relevant, as the same thing happened to me recently. My problem was that I hadn't rebuilt Project A (the child). After rebuilding it, Project A1 (grandchild) could be successfully built, and it's now using the dependency version from the dependencyManagement section in Master (parent).

like image 76
gjoranv Avatar answered Oct 21 '25 15:10

gjoranv


You've given very little information about your project. It sounds like what you want is for Master to have a <dependencyManagement> that sets a version for xyz, and then specify the <dependency> in Project A1 without a version, letting it be dependency-managed by the declaration in Master. All you need for that is for Project A's parent to be Master and Project A1's master to be Project A. And of course, Project A mustn't interfere with the dependency management of artifact xyz. Then just add the <dependencyManagement> and <dependency> appropriately. If you think you're doing that, and it's not working, show some POMs that demonstrate your problem.

like image 42
Ryan Stewart Avatar answered Oct 21 '25 16:10

Ryan Stewart



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!