我可以举一个例子,说明同样的问题,但可能无法回答您的问题。(此外,在此示例中,我使用的是Maven 3知识,但可能不适用于Maven2。)
在多模块maven项目(包含模块A和B,B取决于A)中,您还可以添加对from 的测试依赖项。AB
此依赖关系可能如下所示:
<dependency>
<groupId>com.foo</groupId>
<artifactId>A</artifactId>
<type>test-jar</type> <!-- I'm not sure if there is such a thing in Maven 2, but there is definitely a way to achieve such dependency in Maven 2. -->
<scope>test</scope>
</dependency>
(有关更多信息,请参阅https://maven.apache.org/guides/mini/guide-attached-tests.html)。
请注意,该项目A使用分类器生成辅助工件,该分类器用于tests放置测试类和测试资源。
如果使用构建项目-Dmaven.test.skip=true,只要在本地存储库或外部存储库中未找到测试工件,就会遇到依赖项解析错误。原因是测试类既未编译也未生成tests工件。
但是,如果使用-DskipTests您的tests工件运行构建,则将生成工件(尽管测试不会运行),并将解决依赖性。