When using -am more modules are built than the user might expect

Given a project with four modules A, B, C and D:

  • B and C depend on A
  • D depends on B and C
  • B contains changed/added files
  • A, C and D are unchanged
  • -am is used

then this extension behaves differently than what one might expect:

  • the extension reduces the project list to B and D
  • B because it contains changes
  • D because it depends on B
  • Maven applies -am to the project list: B and D
  • Maven ends up building everthing A (ok, upstream of B), B (ok, changed), D (ok, downstream of B) but also C because D depends on C

In other words this extension is effectively calling mvn ... -pl :B,:D -am whereas a user without this extension would probably call mvn ... -pl :B -am -amd which would only build A, B and D.

I have to add that the current "wider" approach is not entirely wrong or useless! In fact I do need it in a Jenkins pull request (PR) pipeline job which merges the PR with the target branch (I can elaborate more in detail if needed).

So I'd suggest we make this behaviour configurable. Ideas for the property name?