openrewrite / openrewrite/rewrite

Support Maven 4 versionless parent references (parent inference)

Open
#6,869 1 comment 0 reactions 1 assignee View on GitHub

@MBoegers is already working on this.

Since Mar 4, 2026.

maven parser
Dominant language
Java
Stars
3.7k
Forks
570
Avg merge
13h 12m
Merged PRs (30d)
261

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.