Maven unreachable parent pom in unusual relations setup
Asked Answered
R

0

0

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.

Rufescent answered 11/8, 2019 at 10:38 Comment(3)
Are the parent POMs part of the same multi-module project? Or is the subProjectA a multi-module project of its on?Pelion
subprojectA is a standalone project with it's own Git repo. The parents are in other project and not available as source in the same repo.Down
It looks like it's a Maven bug. I found a project that has such configuration and used to work few years back. Also, if it is a user error, then Maven fails with error that does not tell the real nature of the issue (unresolvable artifact). I will fill a Maven bug. But for now, in short: Submodules can't have different parents than the root module. I have switched to the normal layout (the root inherits from external parent, submodules have the root as parent).Down

© 2022 - 2024 — McMap. All rights reserved.