Lifecycle extensions

The lifecycle extensions in Maven allow you to customize the standard build behavior. Let's take a look at the org.apache.maven.AbstractMavenLifecycleParticipant class. A custom lifecycle extension should extend from the AbstractMavenLifecycleParticipant class, which provides the following three methods that you can override:

  • afterProjectsRead(MavenSession session): This method is invoked after all the Maven project instances have been created. There will be one project instance for each POM file. In a large-scale build system, you have one parent POM and it points to multiple child POM files.
  • afterSessionEnd(MavenSession session): This method is invoked after all Maven projects are built.
  • afterSessionStart(MavenSession session) ...

Get Maven Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.