arturobernalg opened a new pull request, #13492:
URL: https://github.com/apache/maven/pull/13492

   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.
   
   ### How
   
   `DefaultInheritanceAssembler` 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.
   
   ### Tests
   
   `DefaultInheritanceAssemblerTest#testInheritedPluginKeepsItsLocation` 
assembles a child with a parent that declares a build plugin and a report 
plugin, and checks that both keep the location of the parent declaration. It 
fails without the change (`expected: not <null>`) and passes with it, three 
runs in a row. I reproduced the original case first through a real project 
build in `maven-core`. spotless is clean.
   
   `maven-impl` passes. `ProjectModelResolverTest` in `maven-core` has 2 
failures (`IllegalArgumentException` instead of `UnresolvableModelException`), 
which also happen without this change on current master. I did not run the 
integration tests.
   
   The issue was reported against 4.0.0-rc-2, so a backport to maven-4.0.x may 
make sense. I can open it after agreement.
   
   ---
   
   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]

Reply via email to