我正在使用maven构建的Java 8项目中。每当我执行mvn install
时,项目的根目录都会被单元测试产生的输出文件污染。
如何将输出重定向到其他地方(可能是目标目录)而不是项目的根目录?
我考虑过重写单元测试以将输出指向目标,但这对我来说似乎有点愚蠢。也许有一个插件或Maven指令可以完成我想完成的工作?
我尝试配置surefire插件,但这没有帮助:(
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<!-- Set working directory for content -->
<workingDirectory>target/test-classes</workingDirectory>
<useFile>false</useFile>
<!-- Just set to some large numbers for all tests to work -->
<argLine>-Xmx1g -Xss1m -XX:MaxPermSize=128m</argLine>
<skipTests>${skip.unit.tests}</skipTests>
</configuration>
</plugin>
答案 0 :(得分:0)
好像我最初的尝试就在那儿,刚刚升级了版本,它就起作用了:)
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<!-- Set working directory for content -->
<workingDirectory>target/test-classes</workingDirectory>
<useFile>false</useFile>
<!-- Just set to some large numbers for all tests to work -->
<argLine>-Xmx1g -Xss1m -XX:MaxPermSize=128m</argLine>
<skipTests>${skip.unit.tests}</skipTests>
</configuration>
</plugin>