Book Image

Mastering Apache Maven 3

Book Image

Mastering Apache Maven 3

Overview of this book

Table of Contents (16 chapters)
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

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): This method is invoked after all Maven projects are built. An extension can use this method to cleanup any of the resources used during the build execution.

  • afterSessionStart(MavenSession session): This method is invoked after the MavenSession...