0

这是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

谢谢

4

1 回答 1

1

部分答案:

1) 没办法。除非您还在主构建部分中配置了这些插件,以便分阶段运行直到打包。

您如何确定插件已运行?maven 输出中是否有类似以下内容?

[信息] --- maven-failsafe-plugin:2.18.1:integration-test (默认)

[信息] --- maven-failsafe-plugin:2.18.1:verify (默认)

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

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

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

请注意,省略了阶段

于 2015-05-20T05:59:46.527 回答