openrewrite / openrewrite/rewrite
Support Maven 4 versionless parent references (parent inference)
Open
@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 nullresolveParentPom()throws immediatelyMavenPomDownloader.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 checkMavenPomDownloader.download()— needs a reactor-only lookup path that accepts null version
Related
- Maven 4 parent inference: https://maven.apache.org/whatsnewinmaven4.html#Parent_inference
- MNG-624
- #6860 laid the groundwork (reactor-first lookup, relaxed path-based matching)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.