对于命令:
mvn -e -U clean compile package install deploy
其中,compile截断究竟被执行几次呢?
实际上是compile被执行4次,package被执行3次,install被执行2次,deploy被执行一次。之所以这样,是跟maven的生命周期有关,具体可参见:http://juvenshun.iteye.com/blog/213959
那么,如何验证呢?其实也很容易,在build元素中添加一个task,并将其指定为compile阶段(或者其他的),task的任务是输出一些内容,用以标记改阶段被执行几次。如下所示:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>this is a message from compile phase!</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>