id, phase, and goals Mean in Maven Plugins?In Maven, when defining a plugin execution inside <executions>, the elements id, phase, and goals determine when and how the plugin runs during the build lifecycle.
Let's break it down:
<id> (Optional, But Useful)<id> is a unique name for the execution.β Example:
<execution>
<id>prepare-agent</id> <!-- Just a name, used for reference -->
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
β If you remove <id>, Maven still runs the execution, but you can't reference it by name.
<phase> (Defines When It Runs)<phase> tells Maven when to run this execution.compile β Compiles Java code.test β Runs unit tests.package β Packages code into .jar or .war.verify β Validates before finishing the build.install β Installs the package into the local repository.deploy β Deploys the artifact.β Example:
<execution>
<id>report</id>
<phase>verify</phase> <!-- This runs AFTER tests are completed -->
<goals>
<goal>report</goal>
</goals>
</execution>
π Why use verify?
test phase, but the JaCoCo report is generated in verify so it doesn't interfere with tests.β If <phase> is missing, Maven does NOT know when to run it!