Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
* or applied in same POM) are always applied. This implementation makes sure, that version and scope are not applied
* onto same node that actually provided the rules, to no override work that ModelBuilder did. It achieves this goal
* by tracking "depth" for each collected rule and ignoring rules coming from same depth as processed dependency node is.
* <p>
* Note for future: the field {@code managedLocalPaths} is <em>intentionally left out of hash/equals</em>, with
* reason explained above.
*
* @since 2.0.0
*/
Expand Down Expand Up @@ -113,15 +116,8 @@ protected AbstractDependencyManager(
// nullable: if using scope manager, but there is no system scope defined
this.systemDependencyScope = systemDependencyScope;

this.hashCode = Objects.hash(
depth,
deriveUntil,
applyFrom,
managedVersions,
managedScopes,
managedOptionals,
managedLocalPaths,
managedExclusions);
// exclude managedLocalPaths
this.hashCode = Objects.hash(depth, managedVersions, managedScopes, managedOptionals, managedExclusions);
}

protected abstract DependencyManager newInstance(
Expand Down Expand Up @@ -185,7 +181,7 @@ public DependencyManager deriveChildManager(DependencyCollectionContext context)
Collection<Exclusion> exclusions = managedDependency.getExclusions();
if (!exclusions.isEmpty()) {
if (managedExclusions == this.managedExclusions) {
managedExclusions = MMap.copy(this.managedExclusions);
managedExclusions = MMap.copyWithKey(key, this.managedExclusions);
}
Collection<Holder<Collection<Exclusion>>> managed = managedExclusions.get(key);
if (managed == null) {
Expand Down Expand Up @@ -320,13 +316,11 @@ public boolean equals(Object obj) {
}

AbstractDependencyManager that = (AbstractDependencyManager) obj;
// exclude managedLocalPaths
return depth == that.depth
&& deriveUntil == that.deriveUntil
&& applyFrom == that.applyFrom
&& managedVersions.equals(that.managedVersions)
&& managedScopes.equals(that.managedScopes)
&& managedOptionals.equals(that.managedOptionals)
&& managedLocalPaths.equals(that.managedLocalPaths)
&& managedExclusions.equals(that.managedExclusions);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.eclipse.aether.util.graph.manager;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;

/**
Expand Down Expand Up @@ -47,6 +49,12 @@ public static <K, V> MMap<K, V> copy(MMap<K, V> orig) {
return new MMap<>(new HashMap<>(orig.delegate));
}

public static <K, V> MMap<K, Collection<V>> copyWithKey(K key, MMap<K, Collection<V>> orig) {
HashMap<K, Collection<V>> delegateLocal = new HashMap<>(orig.delegate);
delegateLocal.computeIfPresent(key, (k, v) -> new ArrayList<>(v));
return new MMap<>(delegateLocal);
}

protected final HashMap<K, V> delegate;

private MMap(HashMap<K, V> delegate) {
Expand Down