arturobernalg opened a new pull request, #13497:
URL: https://github.com/apache/maven/pull/13497
Fixes #8052
### What and why
`PluginParameterExpressionEvaluator(MavenSession)` creates the evaluator
without a `MojoExecution`, but `evaluate()` called
`mojoExecution.getMojoDescriptor()` for every expression. Any `${...}`
therefore failed with a `NullPointerException`, as reported in the issue by a
tool that uses the evaluator outside a mojo execution.
### How
The mojo descriptor is only read when there is a mojo execution. The
`mojo.*` and `plugin.*` expressions need one and have no value without it, so
they evaluate to nothing, like any unknown expression, and fall back to the
properties lookup. All other expressions (`session`, `project`, `basedir`,
user, system and project properties, nested expressions) are evaluated as
before.
### Tests
`PluginParameterExpressionEvaluatorTest` has two new tests that use the
single argument constructor: one for the expressions which do not depend on a
mojo execution, one for the `mojo` and `plugin` expressions. Both fail on
master with the `NullPointerException` of the issue and pass with the change,
three runs in a row. `maven-core` passes (732 tests) and spotless is clean. 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]