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 class
static class
Selection strategy that selects "highest" version.static class
Example selection strategy (used in tests and demos), is not recommended to be used in production.static class
Selection strategy that selects "nearest" (to the root) version.static interface
The strategy how "winner" is being selected.static class
Example selection strategy (used in tests and demos), is not recommended to be used in production. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The name of the version selection strategy to use in conflict resolution: "nearest" (default) or "highest".static final String
static final String
static final String
protected final ConfigurableVersionSelector.SelectionStrategy
The 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 void
backtrack
(ConfigurableVersionSelector.ConflictGroup group, ConflictResolver.ConflictContext context) getInstance
(DependencyNode root, DependencyGraphTransformationContext context) Retrieves the version selector for use during the specified graph transformation.protected boolean
newFailure
(String message, ConflictResolver.ConflictContext context) Helper method to create failure, creates instance ofUnsolvableVersionConflictException
.void
Determines 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.Nearest
strategy.
-
-
Method Details
-
getInstance
public ConflictResolver.VersionSelector getInstance(DependencyNode root, DependencyGraphTransformationContext context) throws RepositoryException Description copied from class:ConflictResolver.VersionSelector
Retrieves 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:
getInstance
in classConflictResolver.VersionSelector
- Parameters:
root
- The root node of the (possibly cyclic!) graph to transform, must not benull
.context
- The graph transformation context, must not benull
.- Returns:
- The scope deriver to use for the given graph transformation, never
null
. - Throws:
RepositoryException
- If the instance could not be retrieved.
-
selectVersion
Description copied from class:ConflictResolver.VersionSelector
Determines 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:
selectVersion
in classConflictResolver.VersionSelector
- Parameters:
context
- The conflict context, must not benull
.- Throws:
RepositoryException
- If the version selection failed.
-
backtrack
protected void backtrack(ConfigurableVersionSelector.ConflictGroup group, ConflictResolver.ConflictContext context) throws UnsolvableVersionConflictException -
isAcceptableByConstraints
protected boolean isAcceptableByConstraints(ConfigurableVersionSelector.ConflictGroup group, Version version) -
toString
-
newFailure
public static UnsolvableVersionConflictException newFailure(String message, ConflictResolver.ConflictContext context) Helper method to create failure, creates instance ofUnsolvableVersionConflictException
.
-