Dependency resolution with -am/-amd

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Dependency resolution with -am/-amd

Mitch Denny

I’m using Maven in a CI scenario right now making use of the -am and -amd switches. We are having an issue right now with how the list of projects to make is solved. Consider the following five projects:

 

A, B, C, D, and E.

 

The dependencies between these projects are as follows:

 

E depends on A

E depends on C

E depends on D

C depends on A

C depends on B

D depends on A

B depends on A

 

So I execute the following command:

 

                mvn install -pl C -am -amd

 

The following happens:

 

                A builds because C depends on it (-am switch)

                B builds because C depends on it (-am switch)

                C builds because it is in the project list (-pl switch)

                E builds because it depends on C … but fails (-amd switch)

                D does not build

 

D is not covered by -am (makes sense) but I was surprised that -amd didn’t result in it getting picked up. I thought that when Maven was resolving the dependencies to build it would see that D was in the graph and in order to successfully build E, it would also need to build D.

 

But it appears that -amd doesn’t work that way. In these scenarios, what is the expected way to resolve this dependency arrangement. Assume that this is just a subset of a larger graph and my intention is not to build the entire graph.

 

One thing that I am considering doing is making D depend explicitly on C via a test dependency. This seems to work, but feels hacky. In a picture this is what our graph looks like:

 

 

 

 

Sent from Mail for Windows 10