简体   繁体   中英

maven failsafe plugin. Copy resources

In my project I have created the following directory structure

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

In my pom.xml I have made following entry

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

If i copy a resource in the src->test->resources it is copied successfully to /target/test-classes automatically. But if I copy a file into /src/integration-test/resources then it is not copied into the target/test-classes at build time.

How can I make the integration test also copy the files inside the resource into the target?

The integration-test goal of the maven-failsafe-plugin in by default bound to the integration-test lifecycle phase: http://maven.apache.org/surefire/maven-failsafe-plugin/integration-test-mojo.html . Therefore, since the integration-test phase comes way after the process-test-sources [1] (during which test sources are usually copied to the target directory) and because I assume what your are referring to by by "build time" is actually the Eclipse "Automatic build" feature, your integration test sources are not copied because Eclipse build stops at the test-compile lifecycle phase.

You should check out Maven lifecycle and how to map certains goal to lifecycle phases that fit your needs.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM