arturobernalg opened a new pull request, #13495:
URL: https://github.com/apache/maven/pull/13495
Backport of #13492 to `maven-4.0.x`. Fixes #10717
### What and why
A plugin that is inherited from a parent POM lost the location of its
`<plugin>` element: `getLocation("")` returned `null`, while it works for a
plugin declared in the project's own POM. Tools use that location to resolve
paths in the plugin configuration against the POM that declares it. The
OpenRewrite Maven plugin does this for `maven-checkstyle-plugin` and fails with
the NPE reported in the issue, which was reported against 4.0.0-rc-2.
### How
`DefaultInheritanceAssembler` in `maven-impl` merges an inherited plugin
into a new instance. The merge copies the fields and their locations, but not
the location of the element itself, which is stored under the empty key. The
merge result now keeps it, for plugins and for report plugins. The change is
the same as on master. The compat `DefaultInheritanceAssembler` in
`maven-model-builder` already sets that location, so it needs no change.
### Tests
`DefaultInheritanceAssemblerTest` has two new tests: an inherited plugin and
report plugin keep the location of the parent declaration, and a plugin
declared by the child keeps its own location. The first one fails without the
change (`expected: not <null>`). Both pass with it, three runs in a row on
`maven-4.0.x`, and spotless is clean. The test file needed a small conflict
resolution in the imports. I did not run the integration tests.
---
To make clear that you license your contribution under
the [Apache License Version 2.0, January
2004](https://www.apache.org/licenses/LICENSE-2.0)
check one of the following:
- [ ] I hereby declare this contribution to be licensed under the [Apache
License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
- [ ] I hereby declare that I have filed an [Apache Individual Contributor
License Agreement](https://www.apache.org/licenses/icla.pdf).
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]