elharo opened a new pull request, #259:
URL: https://github.com/apache/maven-artifact-plugin/pull/259
## Problem
An invalid `buildinfo.ignore` or `buildinfo.skipModules` glob pattern (e.g.
an unclosed character class like `org.example/[`) crashes the build with a raw
`PatternSyntaxException` instead of a clear error.
Two places compiled user-supplied globs without validation:
- `AbstractBuildinfoMojo.isSkipModule()` (lazy `skipModulesMatcher`
compilation)
- `BuildInfoWriter.setIgnore(List<String>)`
Fixes #251.
## Change
- Add package-private `AbstractBuildinfoMojo.compileGlobs(List<String>,
String parameter)` which compiles each glob and wraps a
`PatternSyntaxException` in a `MojoExecutionException` naming the offending
pattern and the parameter that caused it (`Invalid buildinfo.ignore glob
pattern: ...`).
- Validate `buildinfo.skipModules` up front when the goal starts
(`execute()`), and compile the `buildinfo.ignore` globs when the buildinfo
writer is created.
- Reuse the validated matchers: `BuildInfoWriter.setIgnore` now receives
precompiled `PathMatcher`s instead of re-compiling raw strings.
- Thread the checked `MojoExecutionException` through
`isSkip`/`isSkipModule`/`getLastProject`/`getProjectListForBuildInfo` so
invalid globs surface as clear, checked errors in goals that override
`execute()` too (e.g. describe-build-output).
## Test
- New `AbstractBuildinfoMojoTest`:
- `invalidGlobPatternIsReportedWithClearError` asserts an invalid glob
raises `MojoExecutionException` whose message names the parameter and the
pattern.
- `validGlobPatternsCompile` asserts valid globs compile to matchers.
`mvn verify` passes (checkstyle + spotless + rat clean).
--
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]