我有以下结构:
parent-pom (pom)
|
- base-component (with <parent> parent-pom </parent>)(pom)
|
-- child-component (with <parent> base-component </parent>)(jar)
-- some-folder/another-child (with <parent> base-component </parent>)(jar)
在parent-pom中我有像
这样的版本的属性<properties>
<product-version>3.7.8</product-version>
</properties>
当我构建child-component
并使用${product-version}
时 - 它构建没有错误。
但是当我尝试构建another-child
(将子组件作为依赖项)时,即使我设置了${product-version}
,maven也无法读取Could not find artifact base-component
或抛出错误<relativePath>
。 / p>
我认为问题是基本组件和另一个子组件之间的文件夹,但我无法将其移动到升级。
有什么想法吗?
答案 0 :(得分:0)
确保在another-child
模块中正确设置了相对路径。由于它位于另一个目录下,因此其父base-component
应该由两个目录构成:
<parent>
<groupId>...</groupId>
<artifactId>base-component</artifactId>
<version>...</version>
<relativePath>../../pom.xml</relativePath>
</parent>
还要确保在base-component
项目中,模块定义包含another-child
的附加路径,因此它应该类似于:
<modules>
<module>child-component</module>
<module>some-folder/another-child</module>
</modules>
在构建another-child
(或任何其他子模块)之前,尝试从根父级开始构建(mvn install
)整个项目。
答案 1 :(得分:0)
尝试在pom上设置项目目录。
父母:
<properties>
<main.basedir>${project.basedir}</main.basedir>
</properties>
同胞/孩子:
<properties>
<main.basedir>${project.parent.basedir}</main.basedir>
</properties>
子孙:
<properties>
<main.basedir>${project.parent.parent.basedir}</main.basedir>
</properties>