Skip to content

Conversation

@gnodet
Copy link
Contributor

@gnodet gnodet commented May 14, 2025

Description

This PR enhances the PluginDescriptorHelper class to support the getRequiredJavaVersion() and setRequiredJavaVersion() methods directly on the PluginDescriptor class in Maven 4.

Implementation Details

The implementation:

  1. Uses reflection to check if the methods exist in the current Maven version
  2. Tries to use the direct methods first if available (Maven 4)
  3. Falls back to the existing wrapper approach if needed (Maven 3)

This approach ensures backward compatibility while taking advantage of the new methods in Maven 4.

Changes

  • Added static fields to hold method references using reflection
  • Enhanced the existing getRequiredJavaVersion() method to try the direct method first
  • Added a new setRequiredJavaVersion() method following the same pattern
  • Added comprehensive JavaDoc documentation for both methods

Pull Request opened by Augment Code with guidance from the PR author

This commit enhances the PluginDescriptorHelper class to support the getRequiredJavaVersion()
and setRequiredJavaVersion() methods directly on the PluginDescriptor class in Maven 4.

The implementation:
1. Uses reflection to check if the methods exist in the current Maven version
2. Tries to use the direct methods first if available (Maven 4)
3. Falls back to the existing wrapper approach if needed (Maven 3)

This approach ensures backward compatibility while taking advantage of the new methods in Maven 4.
Copy link
Member

Choose a reason for hiding this comment

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

How it will be used?

Why not direct use class from Maven core ... such master branch will be dedicated to Maven 4?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could, but I still think being able to build a maximum of projects targeting Maven 3 with Maven 4 is a good idea. We do want maximum compatibility when possible.
Also, if we target Maven 4, we should move to the new API, but that's more work imho.
So I'd rather to a micro release, and then start migrating this plugin to target Maven 4.

Copy link
Member

Choose a reason for hiding this comment

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

so should we do it in branch: maven-plugin-tools-3.x ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so should we do it in branch: maven-plugin-tools-3.x ?

Yes, I suppose. Not sure we need to do it now, unless someone wants to start the migration asap though.

@gnodet
Copy link
Contributor Author

gnodet commented May 27, 2025

There must be a missing file in this commit, as the helper class is not used at all.

@gnodet gnodet added the bug Something isn't working label Jun 4, 2025
@gnodet gnodet added this to the 4.0.0-beta-2 milestone Jun 4, 2025
@gnodet gnodet merged commit b939390 into master Jun 4, 2025
57 checks passed
@gnodet gnodet deleted the maven4-plugin-descriptor-java-version branch June 4, 2025 09:22
@slawekjaranowski slawekjaranowski added maintenance and removed bug Something isn't working labels Oct 17, 2025
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.

3 participants