There are a few similar questions, but nothing like this. How do you deal with this situation (typical scenario) :
A project of 8-11 child projects, having a parent artifact/project and one main project that mostly uses/declares those others as modules.
The problem is that all projects "strictly" share only the common dependencies, like testng, logging, apache commons and stuff
. But always like 3 of them use 50-60% of the same specific deps (apache-chemistry, jackrabbit, abdera, etc.), another 2-3 of them also use 50-60% of the same but different dependencies. And the main one uses a lot of the same deps.
I cannot put those "non-strictly" shared deps into parent project for others to inherit them. So only the common deps are inherited. And there is tons of duplicate dependencies. And I can only manage their versions via <dependencyManagement>
.
Another option is having parent pom contain most of the dependencies, but child projects inherit even those they don't need.
I could have more than 1 parent project, but it doesn't feel right. Also inheritance from parent project could be nightmare, because you don't know what dependencies the project needs, if you don't document/comment the parent pom definition properly.
Another way is to create pom artifacts that serves only as dependency containers - they declare specific groups of dependencies, so that modules just declare those to gain transitive dependencies. But hey, would you like to deploy and commit some sort of
OneDepArtifact declaring jackrabit, abdera, chemistry
AnotherDepArtifact declaring htmlcleaner, google-api, tika
ThirdDepArtifact declaring spring, httpclient, selenium
It's a huge mess, I'm not sure if I use <dependencyManagement>
correctly, it seems to be only useful for managing dependency versions.
I was thinking of adapting my app development to "maven multimodule design". But If you want to create spring services/beans, that just use various libraries, in one module, you don't implement them in different module, just because they use library that other module also uses :-)
Maven 3.1 should solve this problem by introducing "mixins". In the meantime, it seems that I can get most of the needed features by the proper use of profiles, as I described in this blog post:
http://weblogs.java.net/blog/fabriziogiudici/archive/2011/07/19/maven-pom-composition-means-profiles
Please let me know whether you find it useful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With