-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MENFORCER-470] Add scopes and fail properties to DependencyConvergen…
…ce rule
- Loading branch information
1 parent
95a057b
commit 99383aa
Showing
2 changed files
with
17 additions
and
6 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
import javax.inject.Named; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
@@ -35,8 +36,10 @@ | |
import org.eclipse.aether.graph.DependencyNode; | ||
import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector; | ||
|
||
import static org.apache.maven.artifact.Artifact.SCOPE_PROVIDED; | ||
import static org.apache.maven.artifact.Artifact.SCOPE_TEST; | ||
import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE; | ||
import static org.apache.maven.artifact.Artifact.SCOPE_IMPORT; | ||
import static org.apache.maven.artifact.Artifact.SCOPE_RUNTIME; | ||
import static org.apache.maven.artifact.Artifact.SCOPE_SYSTEM; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Rex Hoffman</a> | ||
|
@@ -50,6 +53,8 @@ public final class DependencyConvergence extends AbstractStandardEnforcerRule { | |
|
||
private List<String> excludes; | ||
|
||
private List<String> scopes = Arrays.asList(SCOPE_COMPILE, SCOPE_RUNTIME, SCOPE_IMPORT, SCOPE_SYSTEM); | ||
|
||
private DependencyVersionMap dependencyVersionMap; | ||
|
||
private final ResolveUtil resolveUtil; | ||
|
@@ -71,8 +76,7 @@ public boolean selectDependency(Dependency dependency) { | |
return !dependency.isOptional() | ||
// regular scope selectors only discard transitive dependencies | ||
// and always allow direct dependencies | ||
&& !dependency.getScope().equals(SCOPE_TEST) | ||
&& !dependency.getScope().equals(SCOPE_PROVIDED); | ||
&& scopes.contains(dependency.getScope()); | ||
} | ||
|
||
@Override | ||
|
@@ -142,7 +146,7 @@ private String buildConvergenceErrorMsg(List<DependencyNode> nodeList) { | |
@Override | ||
public String toString() { | ||
return String.format( | ||
"DependencyConvergence[includes=%s, excludes=%s, uniqueVersions=%b]", | ||
includes, excludes, uniqueVersions); | ||
"DependencyConvergence[includes=%s, excludes=%s, uniqueVersions=%b, scopes=%s]", | ||
includes, excludes, uniqueVersions, String.join(",", scopes)); | ||
} | ||
} |
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