[MNG-6983] Plugin key can get out of sync with artifactId and groupId#372
Closed
PPazderski wants to merge 1 commit intoapache:masterfrom
Closed
[MNG-6983] Plugin key can get out of sync with artifactId and groupId#372PPazderski wants to merge 1 commit intoapache:masterfrom
PPazderski wants to merge 1 commit intoapache:masterfrom
Conversation
The plugin key is build as combination of artifactId and groupId but not updated if either of these two ids change. This can be a problem if artifactId or groupId is a variable. The calculated key will likely contain the unresolved property and is not updated once the variable is interpolated.
asfgit
pushed a commit
that referenced
this pull request
Jun 26, 2021
The plugin key is build as combination of artifactId and groupId but not updated if either of these two ids change. This can be a problem if artifactId or groupId is a variable. The calculated key will likely contain the unresolved property and is not updated once the variable is interpolated. This closes #372
|
Resolve #8395 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
keyfield inPlugin.java. 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.mergePluginContainerPluginstries 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 instancegetKey()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 thekeyif 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
ReportPluginis 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
toStringmethod when inspecting object instances. In case ofPluginthis also triggers the one time calculation ofkey. I.e. inspecting thePluginobject in debugger can change the instance state and as result the issue does not appear anymore or at a different place as without debugging.