Class ConfigurableVersionSelector
java.lang.Object
org.eclipse.aether.util.graph.transformer.ConflictResolver.VersionSelector
org.eclipse.aether.util.graph.transformer.ConfigurableVersionSelector
A configurable version selector for use with
ConflictResolver that resolves version conflicts using a
specified strategy. If there is no single node that satisfies all encountered version ranges, the selector will fail.
Based on configuration, this selector may fail for other reasons as well.- Since:
- 2.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classstatic classSelection strategy that selects "highest" version.static classExample selection strategy (used in tests and demos), is not recommended to be used in production.static classSelection strategy that selects "nearest" (to the root) version.static interfaceThe strategy how "winner" is being selected.static classExample selection strategy (used in tests and demos), is not recommended to be used in production. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of the version selection strategy to use in conflict resolution: "nearest" (default) or "highest".static final Stringstatic final Stringstatic final Stringprotected final ConfigurableVersionSelector.SelectionStrategyThe strategy of winner selection, nevernull. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of this version selector that will use configured selection strategy dynamically.ConfigurableVersionSelector(ConfigurableVersionSelector.SelectionStrategy selectionStrategy) Creates a new instance of this version selector using passed in selection strategy always. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbacktrack(ConfigurableVersionSelector.ConflictGroup group, ConflictResolver.ConflictContext context) getInstance(org.eclipse.aether.graph.DependencyNode root, org.eclipse.aether.collection.DependencyGraphTransformationContext context) Retrieves the version selector for use during the specified graph transformation.protected booleanisAcceptableByConstraints(ConfigurableVersionSelector.ConflictGroup group, org.eclipse.aether.version.Version version) static org.eclipse.aether.collection.UnsolvableVersionConflictExceptionnewFailure(String message, ConflictResolver.ConflictContext context) Helper method to create failure, creates instance ofUnsolvableVersionConflictException.voidDetermines the winning node among conflicting dependencies.toString()
-
Field Details
-
CONFIG_PROP_SELECTION_STRATEGY
The name of the version selection strategy to use in conflict resolution: "nearest" (default) or "highest".- Since:
- 2.0.11
- See Also:
- Sourced from:
RepositorySystemSession.getConfigProperties()- Value type:
String- Default value:
DEFAULT_SELECTION_STRATEGY
-
NEAREST_SELECTION_STRATEGY
- See Also:
-
HIGHEST_SELECTION_STRATEGY
- See Also:
-
DEFAULT_SELECTION_STRATEGY
- See Also:
-
selectionStrategy
The strategy of winner selection, nevernull.
-
-
Constructor Details
-
ConfigurableVersionSelector
public ConfigurableVersionSelector()Creates a new instance of this version selector that will use configured selection strategy dynamically. -
ConfigurableVersionSelector
Creates a new instance of this version selector using passed in selection strategy always.- Parameters:
selectionStrategy- the winner selection strategy, must not benull. Maven3 usedConfigurableVersionSelector.Neareststrategy.
-
-
Method Details
-
getInstance
public ConflictResolver.VersionSelector getInstance(org.eclipse.aether.graph.DependencyNode root, org.eclipse.aether.collection.DependencyGraphTransformationContext context) throws org.eclipse.aether.RepositoryException Description copied from class:ConflictResolver.VersionSelectorRetrieves the version selector for use during the specified graph transformation. The conflict resolver calls this method once perConflictResolver.transformGraph(DependencyNode, DependencyGraphTransformationContext)invocation to allow implementations to prepare any auxiliary data that is needed for their operation. Given that implementations must be stateless, a new instance needs to be returned to hold such auxiliary data. The default implementation simply returns the current instance which is appropriate for implementations which do not require auxiliary data.- Overrides:
getInstancein classConflictResolver.VersionSelector- Parameters:
root- the root node of the (possibly cyclic!) graph to transform, must not benullcontext- the graph transformation context, must not benull- Returns:
- the scope deriver to use for the given graph transformation, never
null - Throws:
org.eclipse.aether.RepositoryException- if the instance could not be retrieved
-
selectVersion
public void selectVersion(ConflictResolver.ConflictContext context) throws org.eclipse.aether.RepositoryException Description copied from class:ConflictResolver.VersionSelectorDetermines the winning node among conflicting dependencies. Implementations will usually iterateConflictResolver.ConflictContext.getItems(), inspectConflictResolver.ConflictItem.getNode()and eventually callConflictResolver.ConflictContext.setWinner(ConflictResolver.ConflictItem)to deliver the winner. Failure to select a winner will automatically fail the entire conflict resolution.- Specified by:
selectVersionin classConflictResolver.VersionSelector- Parameters:
context- the conflict context, must not benull- Throws:
org.eclipse.aether.RepositoryException- if the version selection failed
-
backtrack
protected void backtrack(ConfigurableVersionSelector.ConflictGroup group, ConflictResolver.ConflictContext context) throws org.eclipse.aether.collection.UnsolvableVersionConflictException - Throws:
org.eclipse.aether.collection.UnsolvableVersionConflictException
-
isAcceptableByConstraints
protected boolean isAcceptableByConstraints(ConfigurableVersionSelector.ConflictGroup group, org.eclipse.aether.version.Version version) -
toString
-
newFailure
public static org.eclipse.aether.collection.UnsolvableVersionConflictException newFailure(String message, ConflictResolver.ConflictContext context) Helper method to create failure, creates instance ofUnsolvableVersionConflictException.
-