-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DeploymentDependencySelector equals and hashCode impl
(cherry picked from commit 25941ff)
- Loading branch information
1 parent
3d60256
commit cbafe97
Showing
2 changed files
with
29 additions
and
9 deletions.
There are no files selected for viewing
34 changes: 27 additions & 7 deletions
34
...olver/src/main/java/io/quarkus/bootstrap/resolver/maven/DeploymentDependencySelector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,48 @@ | ||
package io.quarkus.bootstrap.resolver.maven; | ||
|
||
import java.util.Objects; | ||
import org.eclipse.aether.collection.DependencyCollectionContext; | ||
import org.eclipse.aether.collection.DependencySelector; | ||
import org.eclipse.aether.graph.Dependency; | ||
|
||
class DeploymentDependencySelector implements DependencySelector { | ||
final class DeploymentDependencySelector implements DependencySelector { | ||
|
||
static DependencySelector ensureDeploymentDependencySelector(DependencySelector original) { | ||
return original.getClass() == DeploymentDependencySelector.class ? original | ||
: new DeploymentDependencySelector(original); | ||
} | ||
|
||
private final DependencySelector delegate; | ||
|
||
public DeploymentDependencySelector(DependencySelector delegate) { | ||
DeploymentDependencySelector(DependencySelector delegate) { | ||
this.delegate = delegate; | ||
} | ||
|
||
@Override | ||
public boolean selectDependency(Dependency dependency) { | ||
if (dependency.isOptional()) { | ||
return false; | ||
} | ||
return delegate.selectDependency(dependency); | ||
return !dependency.isOptional() && delegate.selectDependency(dependency); | ||
} | ||
|
||
@Override | ||
public DependencySelector deriveChildSelector(DependencyCollectionContext context) { | ||
final DependencySelector newDelegate = delegate.deriveChildSelector(context); | ||
return newDelegate == null ? null : new DeploymentDependencySelector(newDelegate); | ||
return newDelegate == null ? null : ensureDeploymentDependencySelector(newDelegate); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(delegate); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
DeploymentDependencySelector other = (DeploymentDependencySelector) obj; | ||
return Objects.equals(delegate, other.delegate); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters