【问题标题】:maven failsafe plugin. Copy resourcesmaven 故障保护插件。复制资源
【发布时间】:2016-04-14 18:25:38
【问题描述】:

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

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 中,那么它不会在构建时复制到目标/测试类中。

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

【问题讨论】:

    标签: java maven maven-failsafe-plugin


    【解决方案1】:

    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 目录)并且因为我假设您所指的“构建时间”实际上是Eclipse“自动构建”功能,您的集成测试源不会被复制,因为 Eclipse 构建在 test-compile 生命周期阶段停止。

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

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

    【讨论】:

    • 谢谢。我通过这一行解决了它` ${project.basedir}/src/integration-test/resources`
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-09
    • 1970-01-01
    • 2021-09-23
    • 2011-06-26
    相关资源
    最近更新 更多