caiwei-ebay commented on pull request #136:
URL: https://github.com/apache/maven-resolver/pull/136#issuecomment-998529747
@michael-o @cstamas
Squashed the commits. Simplified the algorithm a lot.
**Skip:**
Skip resolving the node if a node with the same GAV and lower (or equal)
depth has been calculated before.
Sample:
- A -> B -> C (C calculated and cached with depth==3)
- A -> E -> F -> C (C will be skipped and children is not set, record this
C has been skipped by above C node)
- A -> C (C re-calculated and cached with depth==2)
- A -> K -> C (C will be skipped, record this C has been skipped by the C
node with path A -> C)
With skip step, there is no result change with "mvn dependency:tree
-Dverbose", and as there would be dependency conflicts,
so "mvn dependency:tree" or "mvn dependency:list" result might be impacted,
thus we need to reconcile.
**Reconcile:**
- A -> B -> C 3.0 -> D -> Z (D of C 3.0 calculated and
cached with depth==4)
- A -> E -> F -> G -> D -> Z (D will be skipped and children
is not set because depth 5 is deeper, record this D has been skipped by above D
node)
- A -> C 2.0 -> H (C 2.0 comes to resolve and
maven will pick C 2.0 as depth is lower. The D of C3.0 in step 1 is no longer
valid, need reconcile the skipped D node in step 2)
Here is the flow:
- Get the cloned root node A by deep cloning the original root node, the
original root node has already been applied above skip strategy.
```
A -> B -> C 3.0 -> D -> Z
A -> E -> F -> G -> D (D has no children as skipped)
A -> C 2.0 -> H
```
- Call Session's transformer to transform the cloned root node A with
verbose mode, note transformer will set children as empty for conflict losers
(ConflictResolver.removeLosers).
```
A -> B -> C 3.0 (C 3.0 has no children as chopped by
transformer)
A -> E -> F -> G -> D (D has no children as skipped)
A -> C 2.0 -> H
```
- Use ReconclingClonedGraphVisitor to iterate the transformed cloned root
node. When visitor comes to a node without children, it can either a skipped
node with no children set or chopped by transformer in step 2)
We just need to reconcile all skipped nodes (the node has no children and
children of original node before transform is also empty).
`D (parent path A -> E -> F -> G) needs to be reconciled`
The visitor also record the dependency conflicts according to the
ConflictResolver.NODE_DATA_WINNER property.
`C 2.0 conflicts with C 3.0`
- Remove cached items from nodesWithDepth if the parent paths of current
node includes any above conflict losers.
```
remove D (children Z, parent path A -> B -> C3.0) from nodesWithDepth
remove Z (parent path A -> B -> C3.0 -> D) from nodesWithDepth
```
- Reconcile the nodes (recalculate their children) found in step 3.
`recalculate D (parent path A -> E -> F -> G, skipped by A -> B -> C3.0
-> D)`
--
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]