开发者

Maven: change the directory in which tests are executed

In my code I have set to create some files in ./ directory, because when the software will be deployed in the installation m开发者_C百科achine, all the configuration files will be created in ./ if it's the first run

Unfortunately when I build the project, and Maven executes tests, all the files are created in the project directory.

I want those files to be created in target/test-run/

How can I do it?

Thanks


If you are using the surefire plugin to execute tests (which is the default), then you can set working directory like this:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.7.2</version>
            <configuration>
                <workingDirectory>${java.io.tmpdir}</workingDirectory>
            </configuration>
        </plugin>
    </plugins>
</build>

Reference: http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html

To set to the specific directory in the question:

<workingDirectory>${project.build.directory}/test-run</workingDirectory>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜