Understanding Maven Lifecycles and JaCoCo | Generated by AI

Home 2025.10

Good question — this comes down to Maven’s lifecycle phases and how plugins bind to them.

Lifecycle basics

Maven has three standard lifecycles: clean, default (sometimes called build), and site. Inside the default lifecycle, the important phases go in order like this:

Each phase includes all the previous ones (if you run mvn verify, Maven executes everything from validate through verify). Running mvn package will stop after creating the artifact (JAR/WAR), and it will not run verify.

Why JaCoCo is involved

The JaCoCo Maven plugin typically binds its prepare-agent goal to the initialize or verify phase depending on configuration.

That’s why you see JaCoCo executed when you run mvn verify but not when you run mvn package.

Practical takeaway

👉 If you want JaCoCo to always run even with mvn package, you can rebind the prepare-agent goal to an earlier phase like test or package in your pom.xml.

Would you like me to show you a concrete pom.xml snippet that makes JaCoCo’s prepare-agent run already at test instead of verify?


Back

openai/gpt-5

Donate