Maven 故障安全插件。复制资源

maven failsafe plugin. Copy resources

在我的项目中我创建了以下目录结构

src
  -> main
       -> java
       -> resources
  -> test
       -> java
       -> resources
  -> integration-test
       -> java
       -> resources

在我的 pom.xml 中,我做了以下条目

        <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.17</version>
            <configuration>
                <testSourceDirectory>src/integration-test/java</testSourceDirectory>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

如果我在 src->test->resources 中复制资源,它会自动成功复制到 /target/test-classes。但是,如果我将文件复制到 /src/integration-test/resources 中,那么它不会在构建时复制到 target/test-classes 中。

如何使集成测试也将资源中的文件复制到目标中?

maven-failsafe-plugin 的 integration-test 目标默认绑定到 integration-test 生命周期阶段:http://maven.apache.org/surefire/maven-failsafe-plugin/integration-test-mojo.html。因此,由于 integration-test 阶段在 process-test-sources [1] 之后(在此期间测试源通常被复制到 target 目录)并且因为我假设你指的是"build time" 实际上是 Eclipse "Automatic build" 功能,您的集成测试源未被复制,因为 Eclipse 构建在 test-compile 生命周期阶段停止。

您应该查看 Maven 生命周期以及如何将某些目标映射到适合您需要的生命周期阶段。

[1] https://maven.apache.org/ref/3.3.9/maven-core/lifecycles.html