Reputation: 10530
I am working on maven project recently but really i do not understand how it works internally as coming from ant background.
Here are basic questions which i tried to google but could not get satisfaction.
1)When i run mvn clean install or mvn clean package. Does install or package goal internally run all plugin one by one defined in pom and parent pom or to run a plugin we need to execute mvn
2)Does all goal of a plugin gets executed ?
3)How goal , phase and task are related to each other?. Consider the below example
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.companyname.projectgroup</groupId>
<artifactId>project</artifactId>
<version>1.0</version>
<profiles>
<profile>
<id>test</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>Using env.test.properties</echo>
<copy file="src/main/resources/env.test.properties" tofile="${project.build.outputDirectory}/env.properties"/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
say if i run mvn test -Ptest, does it mean i am going to run phase test under profile test ?
Upvotes: 0
Views: 1089
Reputation: 3511
Large part of that is illustrated in Introduction to the Build Lifecycle.
Package goals can either be run explicitly as mvn release:perform
(calls perform
goal of maven-release-plugin
) or they can be bound to certain phase. Maven plugins often come with some goals pre-bound. You can define your own binding in your pom.xml
or even specify several different bindings using profiles. In your example, you bind maven-antrun-plugin:run
to phase test
if and only if profile test
is executed.
Upvotes: 1