在我看来,这似乎是个确定的错误。
我有同样的问题,并测试了Maven 3.0.1和3.0.2。验证不会失败,只有编译步骤会失败。随着Maven 3
mvn compile休息,但
mvntest-compile可以。
看起来编译阶段正在反应器中寻找测试罐工件,然后在仓库中进行回购,但不应这样做,因为依赖项在测试范围内。测试范围工件应在测试编译而不是编译期间解决。
结果,我认为可以通过将Maven-compiler-plugin的testCompile目标映射到编译阶段而不是默认的test-compile阶段来解决。
我将其添加到pom中,紧接在上游pom中添加测试罐创建的部分旁边:
<!-- there is a bug in maven causing it to resolve test-jar types at compile time rather than test-compile. Move the compilation of the test classes earlier in the build cycle --> <plugin> <artifactId>maven-compiler-plugin</artifactId> <executions> <execution> <id>default-testCompile</id> <phase>compile</phase> <goals> <goal>testCompile</goal> </goals> </execution> </executions> </plugin>
但这也不起作用,因为在编译和测试-编译之间的五个阶段都没有运行并设置诸如测试类路径之类的东西。
我猜在修正此错误之前,真正的解决方法是使用
test-compile代替
compile。



