我正在尝试设置一个多模块 Maven 项目,并且模块间依赖关系显然没有正确设置。
I have:
<modules>
<module>commons</module>
<module>storage</module>
</modules>
在父 POM 中(有一个打包类型的 pom)
然后是子目录commons/
and storage/
它定义了具有相同名称的 JAR pom。
存储取决于 Commons。
在主(主)目录中,我运行mvn dependency:tree
并看到:
[INFO] Building system
[INFO] task-segment: [dependency:tree]
[INFO] ------------------------------------------------------------------------
[INFO] [dependency:tree {execution: default-cli}]
[INFO] domain:system:pom:1.0-SNAPSHOT
[INFO] \- junit:junit:jar:3.8.1:test
[INFO] ------------------------------------------------------------------------
[INFO] Building commons
[INFO] task-segment: [dependency:tree]
[INFO] ------------------------------------------------------------------------
[INFO] [dependency:tree {execution: default-cli}]
...correct tree...
[INFO] ------------------------------------------------------------------------
[INFO] Building storage
[INFO] task-segment: [dependency:tree]
[INFO] ------------------------------------------------------------------------
Downloading: http://my.repo/artifactory/repo/domain/commons/1.0-SNAPSHOT/commons-1.0-SNAPSHOT.jar
[INFO] Unable to find resource 'domain:commons:jar:1.0-SNAPSHOT' in repository my.repo (http://my.repo/artifactory/repo)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
Missing:
----------
1) domain:commons:jar:1.0-SNAPSHOT
为什么对“commons”的依赖会失败,即使反应器显然已经看到它,因为它成功处理了它的依赖树?它绝对不应该去网上找到它,因为它就在那里......
用于存储的pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<parent>
<artifactId>system</artifactId>
<groupId>domain</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>domain</groupId>
<artifactId>storage</artifactId>
<name>storage</name>
<url>http://maven.apache.org</url>
<dependencies>
<!-- module dependencies -->
<dependency>
<groupId>domain</groupId>
<artifactId>commons</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- other dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
感谢您的任何建议!
(Edit)
为了澄清,我在这里要寻找的是:我不想安装模块 X 来构建依赖于 X 的模块 Y,因为这两个模块都是从同一个父 POM 引用的模块。这对我来说很直观,如果我在同一源树中有两个东西,我就不必安装中间产品来继续构建。希望我的想法在这里有意义......
正如中所讨论的这个 Maven 邮件列表线程 http://www.mail-archive.com/users@maven.apache.org/msg104341.html, dependency:tree 目标本身将在存储库而不是反应器中查找内容。您可以按照之前的建议通过 mvn 安装来解决此问题,或者执行一些不太繁重的调用反应器的操作,例如
mvn compile dependency:tree
对我有用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)