【发布时间】:2024-05-17 21:00:02
【问题描述】:
这是一个 ear 项目的简化示例,父 pom 聚合了 EAR、EJB 和 jar。
我在一个 Maven 项目中有这个结构,存储在 SVN 中:
parent/
|- pom.xml
|- modulA/
| |- pom.xml
|- modulB/
| |- pom.xml
modulB 有一个 modulA 的 Dependency
pom.xml 有模块部分
<modules>
<module>modulA</module>
<module>modulB</module>
</modules>
还有一个依赖管理部分
<dependencyManagement>
<dependencies>
<dependency>
<groupId>group</groupId>
<artifactId>modulA</artifactId>
<version>0.0.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>group</groupId>
<artifactId>modulB</artifactId>
<version>0.0.2-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
子模块引用父模块
<parent>
<groupId>group</groupId>
<artifactId>parent</artifactId>
<version>0.0.2-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
当我第一次使用 maven 2.2.1 (windows) 编译时在我的电脑中
mvn clean compile
我没有任何问题
但是....当 Jenkins 第一次尝试编译时(Maven 2.2.1 Linux RedHat)
Missing:
----------
1) modulA:jar:0.0.2-SNAPSHOT
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=group -DartifactId=modulA -Dversion=0.0.2- SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=group -DartifactId=modulA -Dversion=0.0.2-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) modulB:ejb:0.0.2-SNAPSHOT
2) modulA:jar:0.0.2-SNAPSHOT
----------
1 required artifacts are missing.
为什么??????????
之后,如果我将项目从我的 pc 部署到 Artifactory,Jenkins 就没有问题,因为 Jenkins 从存储库下载工件......但是为什么 Jenkins 依赖于存储库中的工件?
:(
提前致谢
编辑:
我认为dependencyManagement 部分仅“定义”依赖项,但如果子模块不使用依赖项,则不会将依赖项添加到子模块中。 我删除了dependencyManagement部分,Jenkins中的问题仍然存在。
它在我的电脑上运行没有问题。
【问题讨论】:
-
是否有可能为其中一个模块获得有效的 POM?如果它在本地工作,则可能是在引入问题之前,工件已作为开发的一部分部署到本地存储库,这将有效地隐藏它,直到您尝试在新机器上构建(例如构建机器)
-
如果你清理了你的盒子上的本地 maven 存储库,你的盒子第一次构建会失败吗?我猜是的,如果是这样,这意味着您的构建中的某些内容在构建之前引用了 modulA-0.0.2-SNAPSHOT.jar。如果没有看到更多的父级和模块 pom,很难说那是什么。
标签: maven maven-2 jenkins multi-module