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

maven-extension - plexus-component-annotations upgrade has deprecations #1147

Open
breedx-splk opened this issue Jan 4, 2024 · 11 comments
Open

Comments

@breedx-splk
Copy link
Contributor

breedx-splk commented Jan 4, 2024

Component(s)

maven-extension

What happened?

See #1141 for the latest version update to plexus-component-annotations 2.2.0.

It appears that they have deprecated @Component in favor of just using the JSR330 annotations instead. Specifically, instead of using @Component it looks like we can just used @Named. For @Requirement it looks like the recommendation is to use constructor injection an annotate the ctor with @Inject.

@cyrille-leclerc
Copy link
Member

Thanks I'll look at this.

@breedx-splk
Copy link
Contributor Author

Any traction? I think the extension is stalled without a refresh. 🤞🏻

@cyrille-leclerc
Copy link
Member

cyrille-leclerc commented May 20, 2024

Thanks for the heads up.
I'm on it, the migration doesn't work for me for the moment.
I have to simplify the migration steps using a Maven build rather than Gradle and a few other things to be able to engage with Maven community.

Some findings so far:

@cyrille-leclerc
Copy link
Member

cyrille-leclerc commented May 21, 2024

See test Maven extensions https://github.com/cyrille-leclerc/maven-extension-test

Maven Extension APIMaven EventExtension loading mechanism
${maven.home}/lib/extmvn -Dmaven.ext.class.path=pom.xml's <extensions>.mvn/extensions.xml
JSR330AbstractExecutionListener 🔴 🔴 🔴 🔴
JSR330AbstractMavenLifecycleParticipant#afterSessionStart 🟢 🟢 🔴 🟢
JSR330AbstractMavenLifecycleParticipant#afterProjectsRead 🟢 🟢 🟢 🟢
JSR330AbstractMavenLifecycleParticipant#afterSessionEnd 🟢 🟢 🟢 🟢
JSR330AbstractEventSpy#init 🟢 🟢 🔴 🟢
JSR330AbstractEventSpy#onEvent 🟢 🟢 🔴 🟢
JSR330AbstractEventSpy#close 🟢 🟢 🔴 🟢

The OpenTelemetry Maven Extension primarily relies on AbstractExecutionListener which is not supported by Maven's JSR-330 / Sisu APIs but supported by Maven's Plexus APIs.
In order o migrate from Plexus to JSR-330/Sisu APIs, we have either to see with the MAven community if AbstractExecutionListener can b supported by the JSR-330/Sisu APIs or change the APIs we use.

@cyrille-leclerc
Copy link
Member

@hboutemy, hello! A few years ago, I discussed with you the challenges we faced with the OpenTelemetry Maven Extension to replace the Plexus APIs by JSR-330/Sisu.
As we are trying once more to adopt JSR-330/Sisu, I spent the time to detail our problems in the table above with the Maven Extension Events that are missing when using JSR-330/Sisu.
Could you please provide us some guidance on how to move forward?

@cyrille-leclerc
Copy link
Member

cyrille-leclerc commented May 21, 2024

@hboutemy
Copy link

Hi @cyrille-leclerc , thanks for the heads up

I'm surprised AbstractExecutionListener injection works with Plexus but not Sisu: I did my own study a few years ago https://maven.apache.org/studies/extension-demo/ (from source code https://github.com/apache/maven-studies/tree/maven-extension-demo ) and I did not detect that discrepency

reproducing the issue you're facing with such a little project is our best bet to dive into the issue you're facing

@hboutemy
Copy link

I'm surprised AbstractExecutionListener injection works with Plexus but not Sisu

ok, re-reading your example and mine, we only tested AbstractExecutionListener with Sisu/JSR 330, not Plexus and its annotations: do you have an example of Plexus annotations working for AbstractExecutionListener?

@cyrille-leclerc
Copy link
Member

Thanks Hervé, I'll double check with Plexus container.

@hboutemy
Copy link

ok, I had a new look at it and now I understand and can explain: AbstractExecutionListener is not used by Maven core as components (be it Plexus, Sisu or JSR-330), only MavenLifecycleParticipant and EventSpy are components

I updated my extension demo to try to be more clear on it: https://maven.apache.org/studies/extension-demo/

feedback appreciated if more clarification is needed

@cyrille-leclerc
Copy link
Member

cyrille-leclerc commented May 27, 2024

You are right @hboutemy ,

I have added Plexus @Component tests and results to my example https://github.com/cyrille-leclerc/maven-extension-test/blob/main/README.md

AbstractMavenLifecycleParticipant#afterProjectsRead() and AbstractMavenLifecycleParticipant#afterSessionEnd() are the 2 only events that are triggered consistently across the 4 mechanism to load a Maven extension: ${maven.home}/lib/ext, mvn -Dmaven.ext.class.path=..., pom.xml's <extensions>, and .mvn/extensions.xml.

I think I got confused with AbstractExecutionListener due to the page Example: Using Maven 3 lifecycle extension - Lifecycle Extension Points and the statement:

You can extend multiple classes depending on your needs:
org.apache.maven.execution.AbstractExecutionListener,
org.apache.maven.AbstractMavenLifecycleParticipant,
org.apache.maven.eventspy.AbstractEventSpy

The statement above let me think that Maven extensions could extend any of AbstractExecutionListener, AbstractMavenLifecycleParticipant, and AbstractEventSpy through a Plexus extension to hook into Maven lifecycle events but it's not the case, only Plexus instances of AbstractMavenLifecycleParticipant and EventSpy are automatically hooked in the lifecycle.

Your page Maven Core Extension Demo Study is clearer than Example: Using Maven 3 lifecycle extension - Lifecycle Extension Points

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants