build: add maven-enforcer-plugin with Java/Maven/plugin-version rules (E2)#93
Merged
Conversation
… (E2) Wires up Track E2 from the v1.6.5->1.7 readiness taskboard. Binds three rules to the validate phase so the build refuses to start when a precondition is broken: - requireJavaVersion: blocks JDK < 17 (the declared baseline). - requireMavenVersion: blocks Maven < 3.8.0 (oldest version the planned central-publishing pipeline supports). - requirePluginVersions: every plugin must declare an explicit non-LATEST / non-RELEASE / non-SNAPSHOT version. Generalises the PR-7.1 exec-plugin drift lesson. Default-lifecycle plugins (clean, install, site, resources, deploy) are now pinned in a new pluginManagement block so requirePluginVersions has nothing to flag. Versions: clean 3.4.0, install 3.1.4, site 3.21.0, resources 3.3.1, deploy 3.1.4. Minimums and versions live in <properties> so they are visible at the top of the file and easy to bump uniformly. Verification: ./mvnw validate -pl . green (Rule 0/1/2 pass), reactor validate green (root + aggregator + children inheriting parent), full suite still green (~50s).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wires up Track E2 from the v1.6.5→1.7 readiness taskboard. Binds three
maven-enforcer-pluginrules to thevalidatephase so the build refuses to even start when a precondition is broken.The three rules
requireJavaVersion[17,)mvnunder JDK 11 or 15 — "works on my Java 21" drift.requireMavenVersion[3.8.0,)requirePluginVersionsbanLatest=true banRelease=true banSnapshots=trueLATEST/ non-RELEASE/ non-SNAPSHOTversion. Generalisation of the PR-7.1 exec-plugin drift lesson — any unpinned plugin is a future drift.All three values live in
<properties>(enforcer.requireMavenVersion,enforcer.requireJavaVersion,maven.enforcer.plugin.version) so they sit at the top of the file and bump together.<pluginManagement>blockMaven's default lifecycle binds five plugins implicitly (
clean,install,site,resources,deploy).requirePluginVersionswould otherwise flag every one of them. Pinned in a new<pluginManagement>section to the versions Maven 3.9.x currently resolves out of the box:maven-clean-pluginmaven-install-pluginmaven-site-pluginmaven-resources-pluginmaven-deploy-pluginThe explicit pin stops a future Maven upgrade from silently shifting the plugin set we build against.
Verification
Pre-pin, Rule 2 caught the five default plugins listed above — confirming the rule actually works. Post-pin, all three green.
Reactor validate green:
Full suite re-run:
CHANGELOG entry added to
v1.6.6 — Plannedunder### Build.Why this scope
dependencyConvergenceandbanDuplicateClassesare commonly violated by transitive deps that don't impact runtime; they'd add noise without catching real bugs at this stage. Easy to add later if a specific drift incident motivates it.validatephase, notverify. Validate runs before compile, so a broken precondition fails fast — typically inside 1 second. No reason to wait for tests to discover that the JDK is wrong.examples/pom.xmlandbenchmarks/pom.xmlinherit from thegraphcompose-buildaggregator, not the library root, so enforcer doesn't run twice. Intentional — only the library has the precondition contract.Test plan
./mvnw validate -pl .green<pluginManagement>block (~25 LOC) — the only load-bearing partsdependencyConvergencerule when (and if) a transitive-version drift surfaces in production