I'm trying to write a maven extension to calculate the duration of each build session. Here is my extension :
@Parameter( defaultValue = "${project}", readonly = true, required = true )
private MavenProject project;
@Component(role = AbstractMavenLifecycleParticipant.class)
public class BuildTimeLogger extends AbstractMavenLifecycleParticipant {
public void afterSessionStart(MavenSession session) throws MavenExecutionException {
System.out.println("${project}: "+project);
System.out.println("Top level project:"+session.getTopLevelProject());
System.out.println("session.getcurrentproject():"+session.getCurrentProject()); }
}
I'm not sure why all the above print statements print null. Am I using the session object properly? My understanding is that Maven is supposed to send all the session details of the project being built. I tried this on different projects but doesn't seem to work for me.
I played around with this some more and figured that it does print these details when printed from
afterProjectsRead()instead.Pasting from official documentation:
So I think the MavenProject instance is not created yet at afterSessionStart(). Think it could definitely be more descriptive :-/