为集成阶段配置的maven概要文件是否在构建生命周期中执行



这是我项目中pom.xml的压缩片段

   <profiles>
            <profile>
                <id>run-tests</id>
                <build>
                    <plugins>
                        <plugin>
                            <groupId>com.google.code.maven-replacer-plugin</groupId>
                            <artifactId>replacer</artifactId>
                            <version>1.5.2</version>
                            <executions>
                                <execution>
                                    <phase>pre-integration-test</phase>
                                    <goals>
                                        <goal>replace</goal>
                                    </goals>
                                </execution>
                            </executions>
                            <configuration>
                                <includes>
                                   ......
                                </includes>
                                <replacements>
                                    <replacement>
                                       .......
                                    </replacement>
                                </replacements>
                            </configuration>
                        </plugin>
                   <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-failsafe-plugin</artifactId>
                            <version>2.18.1</version>
                            <configuration>
                                ......
                            </configuration>
                            <executions>
                                <execution>
                                    <goals>
                                        <goal>integration-test</goal>
                                        <goal>verify</goal>
                                    </goals>
                                    <phase>integration-test</phase>
                                </execution>
                            </executions>
                        </plugin>
                     </plugins>
    </build>
</profile>
</profiles>

我有两个问题:

1)当我执行mvn clean package -Prun-tests时,会发生什么?我期望这些插件目标都不会在这里执行,因为它们绑定到integration-test阶段。但我看到这些目标执行的原因是什么?

2)execution块中有两个目标意味着什么?请参见上文failsafe-plugin

谢谢

部分答案:

1)不可能。除非您还在主构建部分中配置了这些插件,以便分阶段运行到包。

你如何确定插件已经运行?在maven输出中是否有如下内容?

[INFO]——maven-failsafe-plugin:2.18.1:integration-test(默认)

[INFO]——maven-failsafe-plugin:2.18.1:verify(默认)

2)这意味着两个目标(mojos)将在集成测试阶段执行。首先是集成测试目标,紧接着是验证目标。

注释:集成测试目标默认绑定到集成测试阶段,而验证目标绑定到验证阶段。所以你可以这样配置failsafe插件:

    <executions>
      <execution>
        <goals>
          <goal>integration-test</goal>
          <goal>verify</goal>
        </goals>
      </execution>
    </executions>

注意这个阶段是提交的

最新更新