Maven unreachable parent pom in unusual relations setup

被刻印的时光 ゝ 提交于 2019-12-11 17:24:00

问题


I have a maven project where I need to share 2 levels of common project traits.

One level is project-wide things like remote Maven repo (Artifactory), plugin versions, deps versions.

The other is a complicated mapping of actions to Maven lifecycle, shared for "modules" of a special runtime platform.

The parents are nested:

com.mycompany:projectfoo-parent
  ^-- parent of:
      com.mycompany:projectfoo-module-parent

Each sub-project looks like this:

subprojectA/pom.xml  [ROOT]          <--parent-- projectfoo-parent
subprojectA/modules/ModuleX/pom.xml [MODULE] <--parent-- projectfoo-module-parent
subprojectA/modules/ModuleY/pom.xml [MODULE] <--parent-- projectfoo-module-parent

All parents are in remote Maven repo (SNAPSHOTS).

Now the issue comes when building in a green field (e.g. CI or with -Dmaven.repo.local=localRepo):

    [FATAL] Non-resolvable parent POM for com.mycompany:projectfoo-moduleX:1.0.0-SNAPSHOT: Could not find artifact com.mycompany:projectfoo--module-parent:pom:1.0.0-SNAPSHOT and 'parent.relativePath' points at no local POM @ line 9, column 13
    [FATAL] Non-resolvable parent POM for com.mycompany:projectfoo-moduleY:1.0.0-SNAPSHOT: Could not find artifact com.mycompany:projectfoo--module-parent:pom:1.0.0-SNAPSHOT and 'parent.relativePath' points at no local POM @ line 9, column 13

The -X shows that Maven doesn't even ask the remote repo for these POMs.

I have tried to place the company's remote Maven repo to the parent, to the module-parent, to settings.xml, to the module's pom.xml, ... nothing helped.

What should I do to make Maven look for these parent POMs in the remote repo?

Is my setup even valid? Or is that required that a parent of a (Maven) submodule must be the one that contains it in <modules>? As far as I know, submodules can have arbitrary parent.

A workaround for me could be to bring the parent POMs along and install them to local repo before running Maven, because once it's there, the build works just fine. That also implies that the ids and versions are fine. Also, I have checked that the repo IDs and credentials are correct in settings.xml. Snapshots are enabled for the repo. Maven documentation for that is here.

来源:https://stackoverflow.com/questions/57449258/maven-unreachable-parent-pom-in-unusual-relations-setup

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!