-
Notifications
You must be signed in to change notification settings - Fork 516
Support Maven 4 versionless parent references (parent inference) #6869
Copy link
Copy link
Open
Labels
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
- Fix Maven parser on ${project.version} in parent reference #6860 laid the groundwork (reactor-first lookup, relaxed path-based matching)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
In Progress