對於命令:
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>