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

Provide / describe a way to extend the output #125

Open
laeubi opened this issue Nov 21, 2021 · 7 comments
Open

Provide / describe a way to extend the output #125

laeubi opened this issue Nov 21, 2021 · 7 comments

Comments

@laeubi
Copy link

laeubi commented Nov 21, 2021

Sometimes mojos are performing some sub-task that would be good to appear at the reports.

Is this already possible? If yes it would be nice to document this.
If not, would it be possible to have some kind of custom events to listen to?

@jcgay
Copy link
Owner

jcgay commented Dec 11, 2021

This extension provides a org.apache.maven.eventspy.EventSpy custom implementation.
You can listen to events triggered by Maven execution.

If you're trying to observe specific things done by a mojo, it seems unlikely that the mojo will triggered an event.

You can try do track all the execution of fr.jcgay.maven.profiler.ProfilerEventSpy#onEvent within your build to see if an interesting event comes up but it seems to be a long shot 😇

It should be possible to implements custom events but it implies that a mojo uses org.apache.maven.eventspy.internal.EventSpyDispatcher which lives in an internal package 😅.

@laeubi
Copy link
Author

laeubi commented Dec 12, 2021

If you're trying to observe specific things done by a mojo, it seems unlikely that the mojo will triggered an event.

Just say I have full control over the mojo code could the mojo emit events that are understood by maven-profiler?

@laeubi
Copy link
Author

laeubi commented Dec 12, 2021

org.apache.maven.eventspy.internal.EventSpyDispatcher which lives in an internal package

Thanks for the hint, even though its internal I won't mind using that, do you think maven-profiler could define some kind of custom event that could be used for such purpose?

Another way I could think of would be that maven-profiler provides a (public) component where one could send events directly?

@laeubi
Copy link
Author

laeubi commented Dec 12, 2021

For example ProfilerEventSpy could have a method recordStart(String name) and recordStop(String name) methods or similar where name is used as an identifier?

@jcgay
Copy link
Owner

jcgay commented Dec 18, 2021

I think you're right you may also be able to inject ProfilerEventSpy directly in your mojo (I have not tested it) and call onEvent with a custom event to be implemented in maven-profiler.
How will you report them ? I think they should be linked to the mojo goal running them ?

@laeubi
Copy link
Author

laeubi commented Dec 18, 2021

I think it must not be linked directly to a mojo more something like:

Action A: 30 sec
Action B: 2 sec

and so on...

@laeubi
Copy link
Author

laeubi commented May 13, 2022

I think you're right you may also be able to inject ProfilerEventSpy directly in your mojo (I have not tested it) and call onEvent with a custom event to be implemented in maven-profiler.

I played around a bit with this option and think one might even reuse some events here (e.g. repository download events), sadly this does not work out-of-the-box and I have opened apache/maven#740 to address this.

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

No branches or pull requests

2 participants