-
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-435] Scope TEST and Optional should only apply to Dependen…
…cyConvergence
- Loading branch information
Showing
2 changed files
with
30 additions
and
21 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 |
---|---|---|
|
@@ -21,13 +21,18 @@ | |
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import org.apache.maven.artifact.Artifact; | ||
import org.apache.maven.enforcer.rule.api.EnforcerRule; | ||
import org.apache.maven.enforcer.rule.api.EnforcerRuleException; | ||
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; | ||
import org.apache.maven.plugin.logging.Log; | ||
import org.apache.maven.plugins.enforcer.utils.ArtifactUtils; | ||
import org.apache.maven.plugins.enforcer.utils.DependencyVersionMap; | ||
import org.eclipse.aether.collection.DependencyCollectionContext; | ||
import org.eclipse.aether.collection.DependencySelector; | ||
import org.eclipse.aether.graph.Dependency; | ||
import org.eclipse.aether.graph.DependencyNode; | ||
import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Rex Hoffman</a> | ||
|
@@ -53,7 +58,24 @@ public void execute(EnforcerRuleHelper helper) throws EnforcerRuleException { | |
log = helper.getLog(); | ||
} | ||
try { | ||
DependencyNode node = ArtifactUtils.resolveTransitiveDependencies(helper); | ||
DependencyNode node = ArtifactUtils.resolveTransitiveDependencies( | ||
helper, | ||
// TODO: use a modified version of ExclusionDependencySelector to process excludes and includes | ||
new DependencySelector() { | ||
@Override | ||
public boolean selectDependency(Dependency dependency) { | ||
// regular OptionalDependencySelector only discriminates optional dependencies at level 2+ | ||
return !dependency.isOptional() | ||
// regular ScopeDependencySelector is case-sensitive | ||
&& !dependency.getScope().equalsIgnoreCase(Artifact.SCOPE_TEST); | ||
} | ||
|
||
@Override | ||
public DependencySelector deriveChildSelector(DependencyCollectionContext context) { | ||
return this; | ||
} | ||
}, | ||
new ExclusionDependencySelector()); | ||
dependencyVersionMap = new DependencyVersionMap(log).setUniqueVersions(uniqueVersions); | ||
node.accept(dependencyVersionMap); | ||
|
||
|
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