The current code has extremely special and convoluted handling for multi-module Maven projects. Every multi-module Maven project needs a custom hook in PCT in order to work at all, and even then there are various problems. For example, consider the case of a multi-module Maven project that contains a plugin with a dependency on another plugin in the same multi-module Maven project. An example of this is Pipeline: Declarative Extension Points API, which depends on Pipeline: Model API, both of which are in the same multi-module Maven project. In this case, our current workflow requires two different invocations of PCT, one for each plugin. However, this results in PCT unnecessarily compiling both the dependent and its dependency but only executing tests for the dependent.
At a high level, this should be rewritten so that given a set of plugins, PCT collects a set of repositories containing those plugins and then invokes Maven from the root of each repository. Then we would need no special handling for multi-module Maven projects.
Implementing this should be relatively straightforward: the list of plugins provided can be transformed into a list of repositories, with the main for
loop in org.jenkins.tools.test.PluginCompatTester#testPlugins
converted to loop over repositories rather than plugins, with the semantics of org.jenkins.tools.test.PluginCompatTester#testPluginAgainst
changed to be "test repository against" rather than "test plugin against."
However, one complication is CI callers such as jenkinsci/bom
. These callers take a megawar and list its plugins, invoking parallel runs of PCT, one for each plugin. With the change above to iterate over repositories over plugins, such consumers will want to pass in a list of all plugins that are contained in a given repository rather than passing in a single plugin. For example, to test the pipeline-model-definition-plugin
repository, consumers would want to invoke PCT with --plugins pipeline-model-api,pipeline-model-definition,pipeline-model-extensions,pipeline-stage-tags-metadata
; PCT should then coalesce these into the single repository pipeline-model-definition-plugin
, do one clone, one build, and one test cycle. But how would consumers know to pass in that particular list of plugins?
One solution would be a new PCT flag that, for a given megawar, prints the mapping of repositories to plugins. For example, it could have output like this:
REPOSITORY PLUGINS
pipeline-model-definition-plugin pipeline-model-api,pipeline-model-definition,pipeline-model-extensions,pipeline-stage-tags-metadata
text-finder-plugin text-finder
Consumers would run PCT with this flag to determine the division of parallel branches, each line of the output being a parallel branch (one for each repository). The consumers would pass in the output of the PLUGINS
column as the --plugins
parameter to PCT in each branch.