2

我有一个结构的多模块 Maven 项目

main/
  core/
  interface/

其中interface依赖于core生成的工件。

interface可以正确编译、打包和安装。但是,在interface中运行测试时,由于未解决core中的依赖关系,它们会失败。

interface不依赖于core中的测试类本身,只需编译core pom.xml 文件中定义的范围 maven 依赖项。

我做了一次痛苦的尝试,我将核心中需要的每一个编译依赖声明复制到接口pom.xml 中,并将它们全部提供给

<scope>test</scope>

. 这有助于测试,但破坏了安装。

在interface中修复这些测试的依赖关系解析的最佳方法是什么?

这是运行接口maven 测试目标时未解决的编译范围依赖关系的示例。

核心/pom.xml 摘录:

<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-api</artifactId>
    <version>${jsf-version}</version>
</dependency>
<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-impl</artifactId>
    <version>${jsf-version}</version>
</dependency>

接口/pom.xml 摘录:

<dependency>
  <groupId>com.mycompany</groupId>
  <artifactId>core</artifactId>
  <version>1.0-SNAPSHOT</version>       
</dependency>
4

0 回答 0