gnodet opened a new issue, #13151: URL: https://github.com/apache/maven/issues/13151
## Summary The Maven 4 `Node` API ([`org.apache.maven.api.Node`](https://github.com/apache/maven/blob/master/api/maven-api-core/src/main/java/org/apache/maven/api/Node.java)) does not expose dependency resolution metadata that Aether stores in `DependencyNode.getData()` and via `DependencyManagerUtils`. This information is essential for tools that display verbose dependency trees (conflict indicators, version management overrides, scope changes). ## Missing getters on `Node` The following four pieces of metadata are currently inaccessible through the public Maven 4 API: | Information | Aether source | Used for | |---|---|---| | **Winner node** (conflict loser's winning sibling) | `ConflictResolver.NODE_DATA_WINNER` | "omitted for conflict" display | | **Pre-managed version** (original version before DM override) | `DependencyManagerUtils.getPremanagedVersion()` | "4.4.3 ⚠ 3.25.1" conflict indicator | | **Pre-managed scope** (original scope before DM override) | `DependencyManagerUtils.getPremanagedScope()` | Scope management indicator | | **Original scope** (scope before conflict resolution) | `ConflictResolver.NODE_DATA_ORIGINAL_SCOPE` | Scope conflict display | ## Current workaround Tools like [pilot](https://github.com/maveniverse/pilot) must use reflection to call `AbstractNode.getDependencyNode()` (package-private) to reach the Aether `DependencyNode` and access this data: ```java // TODO: remove reflection once MNG-XXXX is fixed Method m = node.getClass().getDeclaredMethod("getDependencyNode"); m.setAccessible(true); DependencyNode aetherNode = (DependencyNode) m.invoke(node); String premanagedVersion = DependencyManagerUtils.getPremanagedVersion(aetherNode); DependencyNode winner = (DependencyNode) aetherNode.getData().get(ConflictResolver.NODE_DATA_WINNER); ``` Note: `DefaultNode.asString()` already reads all this data internally (it's how `mvn dependency:tree -Dverbose` works), so the underlying plumbing is solid — it just isn't exposed through the API. ## Proposed API additions on `Node` ```java /** * Returns the node that won the dependency conflict resolution for this node, * or empty if this node was not omitted due to a conflict. * Only available when the resolver is run in verbose mode. */ Optional<Node> getWinner(); /** * Returns the version of this dependency as originally declared (before * dependency management overrode it), or empty if it was not managed. * Only available when the resolver is run in verbose mode. */ Optional<String> getPremanagedVersion(); /** * Returns the scope of this dependency as originally declared (before * dependency management overrode it), or empty if the scope was not managed. * Only available when the resolver is run in verbose mode. */ Optional<String> getPremanagedScope(); /** * Returns the scope of this dependency before conflict resolution, * or empty if it was not changed during conflict resolution. * Only available when the resolver is run in verbose mode. */ Optional<String> getOriginalScope(); ``` ## Affected components - `maven-api-core`: `org.apache.maven.api.Node` (new methods) - `maven-impl`: `org.apache.maven.impl.AbstractNode` / `DefaultNode` (implementations) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
