I have a question about maven pom. I have this pom.xml
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>Hello world!</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
when the goal run is executed? Before or after package phase?
(for Maven lifecycle see Maven lifecycle)
Plugin goal is execute after beginning of declared phase (package
), and before beginning of next phase (pre-integration-test
).
In this scenerio maven command
mvn package
should print Hello World
Multiple executions in one phase:
Note: In Maven 2.0.5 and above, multiple goals bound to a phase are executed in the same order as they are declared in the POM, however multiple instances of the same plugin are not supported. Multiple instances of the same plugin are grouped to execute together and ordered in Maven 2.0.11 and above).
and
When multiple executions are given that match a particular phase, they are executed in the order specified in the POM, with inherited executions running first.
Source: Introduction to the Build Lifecycle
In the case you have given it will be executed in the package phase, cause you explicit defined it to be executed during the package phase. If you like to get it executed before the package phase you need to use the prepare-package
phase instead package
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With