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 @@ -54,16 +54,36 @@ public static void main(String[] args) throws Exception {
System.out.println("------------------------------------------------------------");
System.out.println(GetDependencyHierarchyWithConflictsStrategies.class.getSimpleName());

runItWithStrategy(args, ConfigurableVersionSelector.NEAREST_SELECTION_STRATEGY);
runItWithStrategy(args, ConfigurableVersionSelector.HIGHEST_SELECTION_STRATEGY);
CollectRequest collectRequest;

// okttp cleanly shows difference between nearest/closest
collectRequest = new CollectRequest();
collectRequest.setRootArtifact(new DefaultArtifact("demo:demo:1.0"));
collectRequest.setDependencies(
List.of(new Dependency(new DefaultArtifact("com.squareup.okhttp3:okhttp:jar:4.12.0"), "compile")));
runItWithStrategy(args, ConfigurableVersionSelector.NEAREST_SELECTION_STRATEGY, collectRequest);
runItWithStrategy(args, ConfigurableVersionSelector.HIGHEST_SELECTION_STRATEGY, collectRequest);

// MENFORCER-408 inspired
collectRequest = new CollectRequest();
collectRequest.setRootArtifact(new DefaultArtifact("demo:demo:1.0"));
collectRequest.setDependencies(List.of(
new Dependency(new DefaultArtifact("org.seleniumhq.selenium:selenium-java:jar:3.0.1"), "test")));
collectRequest.setManagedDependencies(List.of(
new Dependency(new DefaultArtifact("org.seleniumhq.selenium:selenium-java:jar:3.0.1"), "test"),
new Dependency(new DefaultArtifact("org.seleniumhq.selenium:selenium-remote-driver:jar:3.0.1"), "test"),
new Dependency(new DefaultArtifact("com.codeborne:phantomjsdriver:jar:1.3.0"), "test")));
runItWithStrategy(args, ConfigurableVersionSelector.NEAREST_SELECTION_STRATEGY, collectRequest);
runItWithStrategy(args, ConfigurableVersionSelector.HIGHEST_SELECTION_STRATEGY, collectRequest);
}

private static void runItWithStrategy(String[] args, String selectionStrategy) throws Exception {
private static void runItWithStrategy(String[] args, String selectionStrategy, CollectRequest collectRequest)
throws Exception {
System.out.println();
System.out.println(selectionStrategy);
try (RepositorySystem system = Booter.newRepositorySystem(Booter.selectFactory(args))) {
SessionBuilder sessionBuilder = Booter.newRepositorySystemSession(system);
sessionBuilder.setConfigProperty(ConflictResolver.CONFIG_PROP_VERBOSE, ConflictResolver.Verbosity.FULL);
sessionBuilder.setConfigProperty(ConflictResolver.CONFIG_PROP_VERBOSE, ConflictResolver.Verbosity.STANDARD);
sessionBuilder.setConfigProperty(DependencyManagerUtils.CONFIG_PROP_VERBOSE, true);
sessionBuilder.setConfigProperty(
ConfigurableVersionSelector.CONFIG_PROP_SELECTION_STRATEGY, selectionStrategy);
Expand All @@ -81,10 +101,6 @@ private static void runItWithStrategy(String[] args, String selectionStrategy) t
.setTransferListener(null)
.build()) {

CollectRequest collectRequest = new CollectRequest();
collectRequest.setRootArtifact(new DefaultArtifact("demo:demo:1.0"));
collectRequest.setDependencies(List.of(
new Dependency(new DefaultArtifact("com.squareup.okhttp3:okhttp:jar:4.12.0"), "compile")));
collectRequest.setRepositories(Booter.newRepositories(system, session));

CollectResult result = system.collectDependencies(session, collectRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -806,16 +806,6 @@ private static final class ConflictItem extends ConflictResolver.ConflictItem {
// bit field of OPTIONAL_FALSE and OPTIONAL_TRUE
int optionalities;

/**
* Bit flag indicating whether one or more paths consider the dependency non-optional.
*/
public static final int OPTIONAL_FALSE = 0x01;

/**
* Bit flag indicating whether one or more paths consider the dependency optional.
*/
public static final int OPTIONAL_TRUE = 0x02;

private ConflictItem(DependencyNode parent, DependencyNode node, String scope, boolean optional) {
if (parent != null) {
this.parent = parent.getChildren();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,26 +151,31 @@ public class ConflictResolver implements DependencyGraphTransformer {
*/
public enum Verbosity {
/**
* Verbosity level to be used in all "common" resolving use cases (ie. dependencies to build class path). The
* Verbosity level to be used in all "common" resolving use cases (ie dependencies to build class path). The
* {@link ConflictResolver} in this mode will trim down the graph to the barest minimum: will not leave
* any conflicting node in place, hence no conflicts will be present in transformed graph either.
*/
NONE,

/**
* Verbosity level to be used in "analyze" resolving use cases (ie. dependency convergence calculations). The
* {@link ConflictResolver} in this mode will remove any redundant collected nodes, in turn it will leave one
* with recorded conflicting information. This mode corresponds to "classic verbose" mode when
* Verbosity level to be used in "analyze" resolving use cases (ie dependency convergence calculations). The
* {@link ConflictResolver} in this mode will remove any redundant collected nodes and cycles, in turn it will
* leave one with recorded conflicting information. This mode corresponds to "classic verbose" mode when
* {@link #CONFIG_PROP_VERBOSE} was set to {@code true}. Obviously, the resulting dependency tree is not
* suitable for artifact resolution unless a filter is employed to exclude the duplicate dependencies.
*/
STANDARD,

/**
* Verbosity level to be used in "analyze" resolving use cases (ie. dependency convergence calculations). The
* {@link ConflictResolver} in this mode will not remove any collected node, in turn it will record on all
* eliminated nodes the conflicting information. Obviously, the resulting dependency tree is not suitable
* for artifact resolution unless a filter is employed to exclude the duplicate dependencies.
* Verbosity level to be used in "analyze" resolving use cases (ie dependency convergence calculations). The
* {@link ConflictResolver} in this mode will not remove any collected node nor cycle, in turn it will record
* on all eliminated nodes the conflicting information. Obviously, the resulting dependency tree is not suitable
* for artifact resolution unless a filter is employed to exclude the duplicate dependencies and possible cycles.
* Because of left in cycles, user of this verbosity level should ensure that graph post-processing does not
* contain elements that would explode on them. In other words, session should be modified with proper
* graph transformers.
*
* @see RepositorySystemSession#getDependencyGraphTransformer()
*/
FULL
}
Expand Down
Loading
Loading