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
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..).Currently,
ResolvedPom.resolveParentPom()throwsMavenParsingException("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 485Desired behavior
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 versionRelated