Repository navigation
fix: report file name mapping interpolation failures - #565
efegokdemir wants to merge 3 commits into
Conversation
| // We currently ignore this here, cause assumption is that | ||
| // has already been happened before.. | ||
| // FIXME: Should be checked first. | ||
| Log log = earExecutionContext.getLog(); |
There was a problem hiding this comment.
I'm not sure this is right. I'm not sure this is wrong. But the FIXME seems to indicate that logging is not the right response here.
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
2 open issues
What changed in this PR
This PR ensures file-name mapping interpolation failures are no longer silently swallowed by wiring the Maven Log into EarExecutionContext and emitting a warning when mapping evaluation fails.
Changes:
- Add an optional
LogtoEarExecutionContextwith package-scoped getter/setter. - Set the execution context logger from
AbstractEarMojo. - Log a warning (including the original exception) when
MappingUtils.evaluateFileNameMapping(...)throwsInterpolationException.
| File | Description |
|---|---|
| src/main/java/org/apache/maven/plugins/ear/EarExecutionContext.java | Adds optional Maven Log storage on the execution context. |
| src/main/java/org/apache/maven/plugins/ear/AbstractEarMojo.java | Wires the Mojo logger into the execution context during execution. |
| src/main/java/org/apache/maven/plugins/ear/AbstractEarModule.java | Emits a warning when file-name mapping interpolation fails instead of silently ignoring it. |
Review effort: Lite
| Log log = earExecutionContext.getLog(); | ||
| if (log != null) { | ||
| log.warn("Failed to evaluate file name mapping for [" + this + "]", e); | ||
| } |
| String outputFileNameMapping = earExecutionContext.getOutputFileNameMapping(); | ||
| bundleFileName = MappingUtils.evaluateFileNameMapping(outputFileNameMapping, artifact); | ||
| } catch (InterpolationException e) { | ||
| // We currently ignore this here, cause assumption is that | ||
| // has already been happened before.. | ||
| // FIXME: Should be checked first. | ||
| Log log = earExecutionContext.getLog(); | ||
| if (log != null) { | ||
| log.warn("Failed to evaluate file name mapping for [" + this + "]", e); | ||
| } | ||
| } |
Include the module coordinates alongside the failed file-name mapping in the warning, and assert that both are retained in the regression test.
|

Summary
Changes
Testing
mvn -Dspotless.skip=true -DskipITs -Dinvoker.skip=true test— passed (48 tests)git diff --check— passedmvn -DskipITs -Dinvoker.skip=true test— blocked by the local Palantir Java formatter/JDK incompatibility (NoSuchFieldErrorforJCTree$JCCompilationUnit.endPositions).Fixes #515