lesfurets / partial-build-plugin

A maven plugin for partially building multi-module projects based on changes in the Git repository.
MIT License
40 stars 13 forks source link

Cannot run Sonar on impacted modules if only pom-package module is modified #24

Open robabod opened 6 years ago

robabod commented 6 years ago

In order for Sonar to run on a subset of modules, it necessary to specify each module's parents. For example with a simple project set up as follows, to run Sonar on grandchild1 we need to include container1 and top-level as a minimum.

With the partial-build-plugin we can achieve this by using the following flags:

If we make a change in grandchild1, this has the result of selecting top-level, container1, container2, and grandchild1 to run Sonar on.

The problem we are seeing is that if we make a change to only a pom-package module, then the impacted=true has no effect. For example, if we modify container1/pom.xml, then using the settings above only top-level, container and container2 are selected for Sonar. We would expect grandchild1 to be included, as it could have been affected by the change in its parent container (dependency changes, etc).

If we use partial.impacted=true and partial.ignoreAllReactorProjects=false, then we see container1 and grandchild1 selected, but we cannot run Sonar as we would also need top-level to be included.

It seems as if the ignoreAllReactorProjects flag ignores reactor projects when calculating impact, but this flag seems to be the only way to include parent projects in the build (which Sonar needs).

It would be useful to include an option that includes all parents of selected modules. This could be combined with impacted=true to ensure that all modules that have been impacted by the change can be Sonar'd.

Note that because of the size of our code-base, we build the code multi-threaded, and perform Sonar in a separate single-threaded pass (it doesn't seem to cope with multi-thread).

robabod commented 6 years ago

As a test, I forked the repository and put together a quick change that implements a buildParents parameter, which does roughly what would be needed. It adds all parents of any changed or impacted modules, which would allow running Sonar using the options partial.impacted=true and partial.buildParents=true.

In the example above, if container1/pom.xml were changed, the options would result in top-level, container1 and grandchild1 being built.