Print
Category: IT
Hits: 671

Maven has three default build lifecycles:

default
clean
site

Each lifecycle contains a collection of phases. The phases are passed as argument to mvn, not the lifecycle names.

Calling a phase calls all phases preceding it.

Typicall, a project is built by calling

mvn clean install (clean is not the lifecycle, but a phase within the lifecycle clean)

 

Each phase contains a collection of goals. Adding a goal to a phase:

<build>
 <plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.7</version>
    <executions>
     <execution>
      <id>copy-dependencies</id>
      <phase>package</phase>
      <goals>
       <goal>copy-dependencies</goal>
      </goals>
      <configuration>
       <!-- configure the plugin here -->
      </configuration>
     </execution>
    </executions>
   </plugin>
 </plugins>
</build>