About
A goal is the execution part of a plugin. An individual plugin may have multiple goals. Each goal may have a separate configuration.
If you are familiar with Ant, a goal is similar to a task.
A goal can dependant upon parameters defined in the pom.xml For instance, maven will executes jar:jar if the packaging type of the project is a JAR, and war:war if the packaging type of the project is a WAR.
Since Maven 3.0.3, for two plug-ins bound to the same phase, the order of execution is the same as the order in which you define them in the pom file.
Articles Related
Management
Default
Inside the build node of the pom.xl
<build>
<defaultGoal>clean verify apache-rat:check clirr:check javadoc:javadoc</defaultGoal>
...
</build>
Execution
Format syntax
- with the plugin prefix.
mvn prefix:goal
:: or as the goal default to the name of the prefix
mvn prefix
- with the fully-qualified name:
mvn groupId:artifactId:version:goal
# mvn org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file
where:
- version is by default the latest
- groupId optionally takes its default
Binding
A goal is bind to a project's build lifecycle in the pom.xml file.
See the phase element below.
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
.....
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
..........
</project>