juliojgd opened a new pull request, #1039: URL: https://github.com/apache/maven-enforcer/pull/1039
Resolves [MENFORCER-433](https://issues.apache.org/jira/browse/MENFORCER-433) While building this feature, this contribution has been developed and validated inside InditexTech (team `maven-enforcer-maintainers`), with the intention of contributing it upstream as requested by the Jira issue. **What does this PR add?** A new built-in rule `banPropertyPrefix` that fails the build when the project declares any Maven property whose name starts with one of the configured banned prefixes. It is the counterpart of `requireProperty` and covers the feature request described in MENFORCER-433: sometimes a property must not be set at all (no longer supported, reserved for other tooling, etc.); until now there was no built-in way to enforce that. **Example configuration:** ```xml <rules> <banPropertyPrefix> <prefixes> <prefix>amiga.service</prefix> <prefix>amiga.common</prefix> </prefixes> </banPropertyPrefix> </rules> ``` Each `<prefix>` entry may also contain several comma-separated prefixes: ```xml <rules> <banPropertyPrefix> <prefixes> <prefix>amiga.service,amiga.common</prefix> </prefixes> </banPropertyPrefix> </rules> ``` When a banned property is found, the rule fails listing every offending property and its value: ``` Banned properties found (prefixes: amiga.service): amiga.service.timeout=5000 ``` An optional custom `<message>` can override the default failure message. **Details:** - Implemented following the existing rule patterns ("standard" rule extending `AbstractStandardEnforcerRule`, JSR-330 `@Named("banPropertyPrefix")`, injected `MavenProject`) - Sensible behaviour: empty/blank prefixes are ignored, duplicate prefixes are deduplicated, `stringPropertyNames` traversal, sorted deterministic output in the error message - Unit tests added (`TestBanPropertyPrefix`, 10 tests) covering: banned property found, no match, multiple prefixes, comma-separated entries, blank/duplicate trimming, custom message, cache id - Site documentation added (`banPropertyPrefix.md.vm`) and listed in the built-in rules index Followed the "Making and Submitting Changes" guidelines: topic branch created from `master`, logical unit commits, minimal diffs respecting the existing code style, and all module tests passing (277 tests, `mvn test -pl enforcer-rules`). One note: the same need was recently implemented as a custom rule inside our own framework as well, but we believe having it built-in benefits the whole community — hence this contribution. -- 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]
