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)
: This method is invoked after theMavenSession
instance is created.
Let's try out the following example:
package com.packt.lifecycle.ext; import org.apache.maven.AbstractMavenLifecycleParticipant; import org.apache.maven.MavenExecutionException...