Maven - Goal

Card Puncher Data Processing

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.

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

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

Executing the phase where the goal is/was bind will also execute the goal

mvn phase

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>

Documentation / Reference





Discover More
Card Puncher Data Processing
Maven

is a build tool. It is declarative build tool whereas ant is a procedural build tool. You can then change the build process by changing the process not the declaration. Most of the project declaration...
Card Puncher Data Processing
Maven - Assembly (Plugin)

The assembly plugin will build assembly. An “assembly” is a group of files, directories, and dependencies that are assembled into an archive format and distributed. The plugin goals documentation...
Card Puncher Data Processing
Maven - D Argument

The D maven option define: a system property or an argument for a goal.
Card Puncher Data Processing
Maven - Install (Local Package Installation)

Install is a phase that install the generated artifact in the local repository. deploy Plugin that can be used in this phase. install...
Card Puncher Data Processing
Maven - Package

Packaging in Maven. Package is a phase that bundle the code in a way suitable to be distributed. By default, this phase will take the compiled code and make an archive of it as define in the packaging...
Card Puncher Data Processing
Maven - Phase (Build lifecycle)

A phase is a step in the build lifecycle, which is an ordered sequence of phases. When a phase is given, Maven will execute every phase in the sequence up to and including the one defined. Phases are...
Card Puncher Data Processing
Maven - Plugin (Mojo)

A plugin (in Maven 2.0) groups together goals by code. It's an independent unit of code for Maven. It look like a dependency. In Maven, there are: Build plugins. They will be executed during the...
Card Puncher Data Processing
Maven - Plugin Development

How to develop a maven plugin with Java Annotation. (It's important for the configuration). The code result of this tutorial is on github. gerardnico/helloworld-maven-pluginhelloworld-maven-plugin ...
Maven Execution Id
Maven - Plugin Execution

A plugin execution where: where: executionId see Default ??? default in the POM model default-cli from the command line default-goalName mojo bound to the build lifecycle...
Card Puncher Data Processing
Maven - Project

A project in the Maven sense contains all little pieces that come into play to give code life. Ie: configuration files, the developers involved and the roles they play, the defect tracking system,...



Share this page:
Follow us:
Task Runner