Transitive dependencies and version management

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Transitive dependencies and version management

Halper, Andrew
Greetings,

I was wondering if someone might be able to help with a Maven version
management problem we've encountered.

We have several interdependent, legacy Java projects, that have recently
been re-cast as Maven projects. Now that we have the first iteration done,
it's apparent that one salient characteristic of this particular group of
projects is: there are about a half-dozen "front-end" projects that depend
on an intermediate layer of several projects, which in turn depend on a
rather large, "monolithic" type project at the back. For the sake of
brevity, a set of projects A, depends (selectively) on a set of projects B,
which in turn depend on a single project c (the monolithic one).

A colleague would like to be able to increment the version number of
project c, then recompile the set of projects A, without having to
re-specify c's prerequisite version number occurrences in each pom.xml file
of each (intermediate level) project in B each time project c's version is
incremented. This would almost surely be desired only in development, and
not in a test or production environment.

Could anyone tell me if there is an intrinsic Maven feature that could be
employed here? The present, proposed solution to the problem is to declare
the <scope> of each of c's dependency declarations in each B project's
pom.xml as "provided", but I am uneasy with this. For example, what if
someone wanted to compile a project in B in isolation from the projects in
A?

Thanks very much,
--
Andy Halper
USGS WMA Software Engineering
520 N Park Ave Ste 221
Tucson AZ 85719
Reply | Threaded
Open this post in threaded view
|

Re: Transitive dependencies and version management

Russell Gold-3
Have you considered using snapshot versions for C? If both A and B depend on a snapshot, they will automatically take the latest version in the repository.

https://stackoverflow.com/questions/5901378/what-exactly-is-a-maven-snapshot-and-why-do-we-need-it#5901460

> On Aug 17, 2017, at 8:34 PM, Halper, Andrew <[hidden email]> wrote:
>
> Greetings,
>
> I was wondering if someone might be able to help with a Maven version
> management problem we've encountered.
>
> We have several interdependent, legacy Java projects, that have recently
> been re-cast as Maven projects. Now that we have the first iteration done,
> it's apparent that one salient characteristic of this particular group of
> projects is: there are about a half-dozen "front-end" projects that depend
> on an intermediate layer of several projects, which in turn depend on a
> rather large, "monolithic" type project at the back. For the sake of
> brevity, a set of projects A, depends (selectively) on a set of projects B,
> which in turn depend on a single project c (the monolithic one).
>
> A colleague would like to be able to increment the version number of
> project c, then recompile the set of projects A, without having to
> re-specify c's prerequisite version number occurrences in each pom.xml file
> of each (intermediate level) project in B each time project c's version is
> incremented. This would almost surely be desired only in development, and
> not in a test or production environment.
>
> Could anyone tell me if there is an intrinsic Maven feature that could be
> employed here? The present, proposed solution to the problem is to declare
> the <scope> of each of c's dependency declarations in each B project's
> pom.xml as "provided", but I am uneasy with this. For example, what if
> someone wanted to compile a project in B in isolation from the projects in
> A?
>
> Thanks very much,
> --
> Andy Halper
> USGS WMA Software Engineering
> 520 N Park Ave Ste 221
> Tucson AZ 85719


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Transitive dependencies and version management

Anders Hammar
In reply to this post by Halper, Andrew
What you would do is that you specify the version of C in
dependencyManagement of A. When you then build A, the specified version of
C will be used regardless of what version is specified in B. However, for
thsi to work in runtime this requires the specified version of C to be
compatible with the version that B was compiled with.

I very often, when talking to developers, run into the thinking that (using
your naming) B needs to be re-release whenever there is a new version of C.
You don't have to do that but you could handle that in A using
dependencyManagement. Also, if you utilize api modules and impl modules you
could do this even more beautifully by having B depend on an API artifact
which doesn't change that often.

/Anders

On Fri, Aug 18, 2017 at 2:34 AM, Halper, Andrew <[hidden email]> wrote:

> Greetings,
>
> I was wondering if someone might be able to help with a Maven version
> management problem we've encountered.
>
> We have several interdependent, legacy Java projects, that have recently
> been re-cast as Maven projects. Now that we have the first iteration done,
> it's apparent that one salient characteristic of this particular group of
> projects is: there are about a half-dozen "front-end" projects that depend
> on an intermediate layer of several projects, which in turn depend on a
> rather large, "monolithic" type project at the back. For the sake of
> brevity, a set of projects A, depends (selectively) on a set of projects B,
> which in turn depend on a single project c (the monolithic one).
>
> A colleague would like to be able to increment the version number of
> project c, then recompile the set of projects A, without having to
> re-specify c's prerequisite version number occurrences in each pom.xml file
> of each (intermediate level) project in B each time project c's version is
> incremented. This would almost surely be desired only in development, and
> not in a test or production environment.
>
> Could anyone tell me if there is an intrinsic Maven feature that could be
> employed here? The present, proposed solution to the problem is to declare
> the <scope> of each of c's dependency declarations in each B project's
> pom.xml as "provided", but I am uneasy with this. For example, what if
> someone wanted to compile a project in B in isolation from the projects in
> A?
>
> Thanks very much,
> --
> Andy Halper
> USGS WMA Software Engineering
> 520 N Park Ave Ste 221
> Tucson AZ 85719
>