Reputation: 27173
I am a newbie to Maven . I am reading up Maven - The complete reference and came across the term Plugin Goals under the Build settings
category of a pom.xml file :
In this section, we customize the behavior of the default Maven build. We can change the location of source and tests, we can add new plugins, we can attach plugin goals to the lifecycle, and we can customize the site generation parameters.
Can you please explain with an example what is meant by attaching plugin goal to the lifecycle
?
Upvotes: 1
Views: 107
Reputation: 61538
A plugin goal is a thing that a plugin does. Attaching a plugin goal to the lifecycle is saying to maven: when you are going through the lifecycle and are in this phase, trigger this plugin to do whatever the plugin does. This might sound rather confusing, so let's go through an example:
I want to deploy my application to the server each time I call mvn install
. For this, in the build
section of the pom , I add the following configuration:
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.1.1.Final</version>
<configuration>
...
</configuration>
<executions>
<execution>
<id>deploy-jar</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Take a look at the execution
part: this describes how to attach the deploy
goal of the jboss-as-maven-plugin
to the install
phase of the build lifecycle.
For further explanation of the maven lifecycle and it's phases, read this
Upvotes: 2