Skip to content

Support Maven 4 versionless parent references (parent inference) #6869

@MBoegers

Description

@MBoegers

Problem

Maven 4 (model version 4.1.0) allows omitting <version> from <parent> elements. The parent coordinates are inferred from the POM found at <relativePath> (defaulting to ..).

<parent>
  <groupId>com.example</groupId>
  <artifactId>parent</artifactId>
  <!-- version omitted — inferred from ../pom.xml -->
</parent>

Currently, ResolvedPom.resolveParentPom() throws MavenParsingException("Parent version must always specify a version") when the version is null. Since OpenRewrite only parses POMs from successful builds, a null parent version implies a valid Maven 4 project.

Current behavior

  • Pom.getParent().getGav().getVersion() returns null
  • resolveParentPom() throws immediately
  • MavenPomDownloader.download() also rejects null version at line 485

Desired behavior

  • If parent version is null, attempt reactor lookup via relative path + groupId/artifactId match
  • If found, use the local parent POM (version inferred from it)
  • If not found in reactor, throw MavenParsingException (no remote fallback without a version)

Scope

  • ResolvedPom.resolveParentPom() — handle null version before the existing placeholder check
  • MavenPomDownloader.download() — needs a reactor-only lookup path that accepts null version

Related

Metadata

Metadata

Assignees

Labels

Type

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions