Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNG-7947] Plugin API #1309

Merged
merged 11 commits into from
Dec 5, 2023
Merged

[MNG-7947] Plugin API #1309

merged 11 commits into from
Dec 5, 2023

Conversation

gnodet
Copy link
Contributor

@gnodet gnodet commented Nov 16, 2023

Switch to Guice 6.0, use guice to instantiate and inject mojos

Context: my goal for the maven API was to be completely independent of any third party library. I was working this week on migrating some parts of the Plugin API for Maven 4. Unfortunately, the scopes (@SessionScoped and @MojoExecutionScoped) need to be annotated by a scope annotation so that they are recognised as such by Guice. So either the guice annotation or the javax.inject one. Given javax.inject will slowly go away, I went straight to jakarta.inject, thus upgrading to Guice 6.0 (which supports both javax.inject and jakarta.inject, while Guice 7.0 only supports jakarta.inject).

Maven 4 api for plugin execution

This introduces an immutable plugin descriptor (and custom lifecycle for plugins too). The Maven 3 PluginDescriptor contains runtime information such as the class loader, dependencies, etc... Those are moved to the o.a.m.api.Plugin class which can be accessed from the o.a.m.api.MojoExecution along with the MojoDescriptor and PluginDescriptor.

Leveraging guice, some fields inherited from the plexus land now disappear: instantiationStrategy is replaced with scope annotations, @Component replaced by @Inject.

@cstamas
Copy link
Member

cstamas commented Nov 17, 2023

@mcculls please chime in

Copy link
Contributor

@elharo elharo left a comment

Choose a reason for hiding this comment

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

I'm not familiar with these specific annotations. However I've noticed in some cases only the simple name of the annotation matters, not the package. If that applies here, you could define Maven specific annotations with the right name rather than depending on Guice.

@gnodet
Copy link
Contributor Author

gnodet commented Nov 20, 2023

I'm not familiar with these specific annotations. However I've noticed in some cases only the simple name of the annotation matters, not the package. If that applies here, you could define Maven specific annotations with the right name rather than depending on Guice.

Yeah, that's true for some annotations, unfortunately, guice is very specific about which ones are used, so it does not work here, see https://github.com/google/guice/blob/6.0.0/core/src/com/google/inject/internal/Annotations.java#L350

@gnodet gnodet changed the title Plugin API [MNG-7947] Plugin API Nov 28, 2023
@gnodet gnodet merged commit 23bca28 into apache:master Dec 5, 2023
18 checks passed
@gnodet gnodet deleted the plugin-api branch December 5, 2023 08:11
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.

3 participants