You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "gnodet (via GitHub)" <gi...@apache.org> on 2026/09/15 23:53:01 UTC

[I] Node API: expose dependency resolution metadata (winner, pre-managed version/scope, original scope) [maven]

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: issues-unsubscribe@maven.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Node API: expose dependency resolution metadata (winner, pre-managed version/scope, original scope) [maven]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on issue #13151:
URL: https://github.com/apache/maven/issues/13151#issuecomment-5693518901

   Also related to this issue: a tool using the Maven 4 standalone API needs to enable verbose mode on the `RepositorySystemSession` to get the pre-managed version/scope data populated in `DependencyNode.getData()`. Currently this requires importing `DependencyManagerUtils.CONFIG_PROP_VERBOSE` from `maven-resolver-util` (an Aether internal):
   
   ```java
   mutableSession.setConfigProperty(DependencyManagerUtils.CONFIG_PROP_VERBOSE, Boolean.TRUE);
   ```
   
   It would be useful to expose this as a proper Maven API constant, or — better — have `DependencyResolverRequest` / the `DependencyResolver` service respect a `verbose` flag already (which `DefaultDependencyResolver` does internally when `request.getVerbose()` is set). The issue is that for tools collecting the tree directly via `RepositorySystem.collectDependencies()` (e.g. to avoid full resolution), there is no Maven API way to request verbose mode without reaching into Aether internals.
   
   **Proposed addition:** a constant on `DependencyResolverRequest` or on a new `ResolverOptions` type in `maven-api-core`:
   ```java
   // in maven-api-core, e.g. on DependencyResolverRequest or a new ResolverVerbosity enum
   boolean isVerbose(); // already exists on DependencyResolverRequest — but not accessible for raw collectDependencies
   ```
   
   Or more simply: expose `DependencyManagerUtils.CONFIG_PROP_VERBOSE` as a constant on a Maven API type so tools don't need to depend on `maven-resolver-util` just to set it.
   
   _Guillaume Nodet_
   


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Node API: expose dependency resolution metadata (winner, pre-managed version/scope, original scope) [maven]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on issue #13151:
URL: https://github.com/apache/maven/issues/13151#issuecomment-5693751901

   > [@gnodet](https://github.com/gnodet) This is interesting and can work on this along the proposed direction: expose the four metadata accessors on `Node`, preserve their behavior through filtered nodes, and add regression coverage for conflict winners, managed versions/scopes, and absent metadata.
   > 
   > I’d start with a small dependency-graph reproducer based on Pilot’s use case, keeping Resolver types out of the public API. Does that scope work ?
   
   @goutamadwant please go ahead ,thx !


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Node API: expose dependency resolution metadata (winner, pre-managed version/scope, original scope) [maven]

Posted by "goutamadwant (via GitHub)" <gi...@apache.org>.
goutamadwant commented on issue #13151:
URL: https://github.com/apache/maven/issues/13151#issuecomment-5690369790

   @gnodet This is interesting and can work on this along the proposed direction: expose the four metadata accessors on `Node`, preserve their behavior through filtered nodes, and add regression coverage for conflict winners, managed versions/scopes, and absent metadata.
   
   I’d start with a small dependency-graph reproducer based on Pilot’s use case, keeping Resolver types out of the public API. Does that scope work ?


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Node API: expose dependency resolution metadata (winner, pre-managed version/scope, original scope) [maven]

Posted by "arturobernalg (via GitHub)" <gi...@apache.org>.
arturobernalg commented on issue #13151:
URL: https://github.com/apache/maven/issues/13151#issuecomment-6096572053

   @goutamadwant I had a look at this as well and have a working implementation of the four `Node` accessors with tests, including preserving the metadata through filtered nodes.
   
   I noticed Guillaume had already asked you to go ahead with it. Are you still working on this? If not, I can open the PR from my implementation.


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org