Skip to content

Option to use Enforcer rule for obsolete dependency management#1381

Draft
jglick wants to merge 13 commits intojenkinsci:masterfrom
jglick:dependencyManagement
Draft

Option to use Enforcer rule for obsolete dependency management#1381
jglick wants to merge 13 commits intojenkinsci:masterfrom
jglick:dependencyManagement

Conversation

@jglick
Copy link
Copy Markdown
Member

@jglick jglick commented Apr 27, 2026

Downstream of jenkinsci/maven-hpi-plugin#883. For now I am letting this be opt-in since the implementation is a bit crufty and there are surely a lot of edge cases.

  • basically works (tested interactively in oidc-provider and in some CloudBees CI plugins)
  • figure out how to run ITs against hpi-plugin.version=999999-SNAPSHOT (Enforcer croaks with a CNFE; workaround: wait until CI publishes an incremental of each upstream commit)

jglick and others added 2 commits April 21, 2026 18:38
- Add maven-hpi-plugin as dependency to maven-enforcer-plugin
- Add requireNonObsoleteDependencyManagement rule to display-info execution
- Add smoke test IT verifying rule loads and detects obsolete overrides
- Add skip-property IT verifying plugins can disable via property

The rule will activate once an incremental release of maven-hpi-plugin
containing the rule is available. Until then, the ITs demonstrate the
configuration is correct but will fail with the current stable version.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Configure rule in display-info execution after requireUpperBoundDeps
- Add ignorePattern for junit:junit (intentionally managed by plugin-pom, but appears in guice-bom's effective dependencyManagement)
- Update hpi-plugin.version to 3.1820.vd1b_1b_09038b_e (incremental with the rule)

The junit:junit exclusion is needed because jenkins-bom imports guice-bom
(jenkinsci/jenkins#6014), and guice-bom inherits junit:junit:4.13.2 from
guice-parent for guice-testlib support. This conflicts with plugin-pom's
intentional management of test library versions.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Comment thread pom.xml

Note: jenkins-bom imports guice-bom (added in jenkinsci/jenkins#6014),
which transitively brings junit into jenkins-bom's effective dependencyManagement.
This decision may need to be revisited - see jenkinsci/jenkins#6014.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jglick jglick mentioned this pull request Apr 27, 2026
Comment thread pom.xml
Comment on lines +1016 to +1017
<writeJunitReport>true</writeJunitReport>
<junitPackageName>io.jenkins.tools.plugin_pom.its</junitPackageName>
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jglick jglick changed the title Use Enforcer rule for obsolete dependency management Option to use Enforcer rule for obsolete dependency management Apr 28, 2026
jglick and others added 2 commits April 28, 2026 19:00
Since a91c5cc the rule is skipped by default, so add an integration test
that explicitly opts in (skip=false) and verifies the build passes when
there are no obsolete overrides.

Also improve the postbuild assertions to check for specific log messages
that confirm the rule actually executed rather than being skipped.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an opt-in Maven Enforcer rule (sourced from maven-hpi-plugin) to detect obsolete dependencyManagement overrides, along with new integration tests to validate failing, passing, and skipped scenarios.

Changes:

  • Bump maven-hpi-plugin version and wire it as a dependency of maven-enforcer-plugin to expose the new rule.
  • Add opt-in property requireNonObsoleteDependencyManagement.skip (defaulting to skip) and configure the rule with an ignore pattern.
  • Add 3 new Maven Invoker ITs covering: clean (no overrides), smoke (obsolete override fails), and skip-property (rule skipped).

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pom.xml Enables/configures the new enforcer rule (opt-in via skip property), bumps HPI plugin version, and emits JUnit reports for IT runs.
consume-incrementals Tracks the upstream PR this change depends on.
src/it/bom-obsolete-override-clean/pom.xml IT project verifying “no obsolete overrides” case when the rule is enabled.
src/it/bom-obsolete-override-clean/invoker.properties Runs the clean IT with standard goals.
src/it/bom-obsolete-override-clean/postbuild.groovy Asserts the rule executed and reported no violations.
src/it/bom-obsolete-override-clean/src/main/resources/index.jelly Minimal Jelly view required for an HPI IT project.
src/it/bom-obsolete-override-smoke/pom.xml IT project with an intentionally obsolete override to ensure the rule fails the build when enabled.
src/it/bom-obsolete-override-smoke/invoker.properties Runs the smoke IT and expects a failure result.
src/it/bom-obsolete-override-smoke/postbuild.groovy Asserts the rule executed and detected the obsolete override in logs.
src/it/bom-obsolete-override-smoke/src/main/resources/index.jelly Minimal Jelly view required for an HPI IT project.
src/it/bom-obsolete-override-skip-property/pom.xml IT project intended to verify the rule is skipped when the skip property is enabled/defaulted.
src/it/bom-obsolete-override-skip-property/invoker.properties Runs the skip-property IT with standard goals.
src/it/bom-obsolete-override-skip-property/postbuild.groovy Asserts the rule was skipped and no violation message appears.
src/it/bom-obsolete-override-skip-property/src/main/resources/index.jelly Minimal Jelly view required for an HPI IT project.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/it/bom-obsolete-override-skip-property/pom.xml
Comment thread src/it/bom-obsolete-override-skip-property/pom.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants