[NETBEANS-6519] Maven dependency produces full tree with duplicates, avoids cycles. #4947
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See also NETBEANS-6519
The main issue with the implementation was that the 1st encountered Dependency from Maven might be truncated / stripped of its children - and marked as a duplicate. However in the dependency API all dependencies are "equal", we cannot assume that a client does depth-first or breadth-first traversal.
With the fix, the dependency tree will be enormous, as each common library dependency will introduce a full subtree at the library's place in the dependency tree.
I plan to add an additional API to mark duplicates (= subtrees with the same contents) and possibly resolution conflicts (an artifact dependency has been resolved by a different artifact, e.g. a different version of a library). But this fix is simple and allows clients to enumerate all dependencies. Clients can now filter the duplicates themselves, according to their needs.