maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <>
Subject [GitHub] [maven] PPazderski opened a new pull request #372: [MNG-6983] Plugin key can get out of sync with artifactId and groupId
Date Tue, 08 Sep 2020 18:08:07 GMT

PPazderski opened a new pull request #372:

   I came here because of a project where some maven plugins are not executed without any
warning or error. Debugging the issue brought me to the implementation of the `key` field
in ``. It constructs the key _once_ on first use from the plugins groupId and artifactId.
The key is not updated when either of this values changes.
   It is not easy for me to say where exactly this construct start to fail, but take a look
on the following screenshot. At one point `ManagementModelMerger.mergePluginContainerPlugins`
tries to enhance the child pom plugin instance with the version information from the parents
pluginManagement. But it fails to match both plugin instances. Both plugins have the same
(interpolated) groupId and artifactId but different keys. Obviously for one instance `getKey()`
was called before the groupId was interpolated but not for the other, resulting in different
keys for the same plugin.
   My suggested fix is to basically follow the TODO comment found on `key`. Reset the `key`
if groupId or artifactId changes. Since the key calculation is so simple I actually see no
reason to cache it at all.
   Furthermore, while writing this description, I noticed that the implementation of `ReportPlugin`
is very similar (looks like it was copy&pasted at one point) and it already does what
I propose for this pull request.
   PS: an additional note and warning if you want to debug the current code. All debuggers
I know tend to call the `toString` method when inspecting object instances. In case of `Plugin`
this also triggers the _one time calculation_ of `key`. I.e. inspecting the `Plugin` object
in debugger can change the instance state and as result the issue does not appear anymore
or at a different place as without debugging.

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:

View raw message