Lifecycle extensions

The lifecycle extensions in Maven allow you to customize the standard build behavior. Let's have a look at the org.apache.maven.AbstractMavenLifecycleParticipant class. Your 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 MavenProject 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. This method can be used by an extension to manipulate the Maven projects prior to build execution.
  • afterSessionEnd(MavenSession session) ...

Get Mastering Apache Maven 3 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.