maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen Connolly <>
Subject Re: How to resolve right dependency which enabled and built/install with profile?
Date Tue, 10 Dec 2013 10:57:00 GMT
Using profiles to manipulate dependencies is a route to madness.

An modules dependencies should be a constant... It was a mistake to allow
<dependencies> within <profile>.

The correct solution is to create additional modules that aggregate in the
corresponding lib versions (this is also a bad plan, but less worse than
your current plan by quite some margin). The additional modules would
depend on A and the respective version of libjar and bundle the two

Then B can depend if the corresponding internmediate... Now at this point
you will start to see the madness returning... That is if you need two
versions of B.

The better solution is to just let B depend in A and then do the fatjar as
the final later after B and *override* the transitive dep on libjar in the
two fatjar building modules

On Tuesday, 10 December 2013, Liu, Raymond wrote:

> Hi
> I have a project with module A that will be built with or without profile
> say -Pnewlib , thus I can have it build with different version of library
> dependency let's say by default use libjar-1.0 and when -Pnewlib will use
> libjar-2.0.
> Then, I have a module B to depends on module A. The issue is that how can
> I get the right dependency in module B for libjar? I want to assemble a fat
> jar so I need to figure out which version of libjar to include.
> In my test, it seems to me that when mvn -Pnewlib install module A, though
> it will build with libjar-2.0. but the installed pom do not reflect this.
> Thus when module B resolve the dependency, it will resolve the dependency
> as libjar-1.0 ( though when building module B, -Pnewlib is also passed in,
> But I think this will not pass to the dependent package when resolve the
> dependency).
> I don't want to have module B know anything about the libjar-1.0 and
> libjar-2.0. it should handle by module A, and module B just simply call
> into module A.
> Actually, I think this apply the same if A and B are not modules in one
> project, but standalone projects. In which case B will not define profile
> at all.
> So how can I achieve this goal? say, A take care of lib dependency when
> build and install. B who depends on A, when assembly can retrive the right
> lib dependency.
> Best Regards,
> Raymond Liu
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: <javascript:;>
> For additional commands, e-mail:<javascript:;>

Sent from my phone

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message