Skip to content

Conversation

Copy link

Copilot AI commented Nov 1, 2025

  • Rebased onto latest master (commit 95e3695)
  • Resolved conflicts successfully (no conflicts found)
  • All 224 tests pass (including 5 new unit tests)
  • Manual testing confirms goal still works correctly
  • Build succeeds without errors
  • Created comprehensive unit and integration tests
  • Refactored to use generic base class pattern for extensibility

Implementation

Created a generic UsePluginVersionsMojoBase base class (following the pattern of UseLatestVersionsMojoBase for dependency updates) that enables:

  • Extensibility: Easy to create additional plugin update goals (e.g., use-next-plugin-releases)
  • Code reuse: Common plugin update logic is in the base class
  • Consistent API: Similar abstract methods as dependency update base class

Added UseLatestPluginReleasesMojo that extends the base class and:

  • Updates plugin versions in <build><plugins> and <build><pluginManagement><plugins> sections
  • Respects version constraints via allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates parameters
  • Skips property-based versions (e.g., ${compiler.version})
  • Uses existing infrastructure (PomHelper.setPluginVersion, ArtifactVersions.getNewerVersions, createMavenPluginArtifact)

Architecture

The generic base class UsePluginVersionsMojoBase provides:

  • Abstract methods for version selection strategy
  • Common plugin collection and update logic
  • Support for processPlugins and processPluginManagement parameters
  • Foundation for creating additional plugin update mojos

Testing

Unit Tests (5 tests)

  • Mojo instantiation test
  • Tests for processPlugins, processPluginManagement, and allowMajorUpdates parameters
  • Test for skipping plugins with property-based versions

Integration Tests (3 tests)

  • it-use-latest-plugin-releases-001: Tests basic plugin update functionality
  • it-use-latest-plugin-releases-002: Tests version constraints with allowMajorUpdates=false
  • it-use-latest-plugin-releases-003: Tests processPlugins=false parameter

Usage

# Update all plugin versions to latest releases
mvn versions:use-latest-plugin-releases

# Restrict to minor/patch updates only
mvn versions:use-latest-plugin-releases -DallowMajorUpdates=false

# Update only plugins section, skip pluginManagement
mvn versions:use-latest-plugin-releases -DprocessPluginManagement=false

Example

Before:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.0</version>
</plugin>

After running goal:

[INFO] Updated org.apache.maven.plugins:maven-compiler-plugin from 3.8.0 to 3.14.1

Addresses enhancement request from issue #8.

Original prompt

This section details on the original issue you should resolve

<issue_title>Enhancement: Goal to update plugin versions.</issue_title>
<issue_description>I can use versions:display-plugin-updates to see which plugins can be updated. However, there's no goal to actually edit the pom.xml file to enact those changes.

There's a goal to do this for dependencies: versions:use-latest-releases or versions:use-next-releases.
I can do the same for dependency versions that I've extracted to properties: versions:update-properties.
But I can't automatically do that for plugin versions.</issue_description>

Comments on the Issue (you are @copilot in this section)

@andrzejj0 Looks like `processPlugins` and something for 2.18. @andrzejj0 This is not stale, but this is a duplicate of #8. It's in the works (for quite a while).

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@andrzejj0
Copy link
Contributor

andrzejj0 commented Nov 1, 2025

Please do not merge anything until my PR #1284 is merged in. Otherwise I will need to do another costly conflict resolution.

I'm also abstracting out a thin version of VersionsHelper which is a single responsibility thin wrapper over Resolver.

Copilot AI changed the title [WIP] Add goal for updating plugin versions in pom.xml Add use-latest-plugin-releases goal for automated plugin version updates Nov 1, 2025
Copilot AI requested a review from slachiewicz November 1, 2025 08:32
@slachiewicz

This comment was marked as resolved.

This comment was marked as resolved.

@slachiewicz slachiewicz force-pushed the copilot/enhance-plugin-version-update branch from 66f4754 to 322124d Compare November 3, 2025 12:50
@slachiewicz
Copy link
Member

@copilot create unit and integration tests for UseLatestPluginReleasesMojo

This comment has been minimized.

@slachiewicz slachiewicz marked this pull request as ready for review November 3, 2025 13:07
@slachiewicz slachiewicz marked this pull request as draft November 3, 2025 13:08
@slachiewicz

This comment has been minimized.

Copy link
Author

Copilot AI commented Nov 3, 2025

@copilot make it more generic - take idea from #292

Refactored to use a generic base class pattern in commit 8198446.

Created UsePluginVersionsMojoBase (similar to UseLatestVersionsMojoBase) that:

  • Provides common plugin update logic
  • Defines abstract methods for version selection strategy
  • Enables creating additional plugin update goals (e.g., use-next-plugin-releases)

The refactored UseLatestPluginReleasesMojo now extends this base class, maintaining all existing functionality while enabling future extensibility. All 224 tests pass.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/mojohaus/versions/pulls/292
    • Triggering command: curl -s REDACTED (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@slachiewicz slachiewicz deleted the copilot/enhance-plugin-version-update branch November 11, 2025 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: Goal to update plugin versions.

2 participants