Class ConfigurableVersionSelector
- java.lang.Object
-
- org.eclipse.aether.util.graph.transformer.ConflictResolver.VersionSelector
-
- org.eclipse.aether.util.graph.transformer.ConfigurableVersionSelector
-
public class ConfigurableVersionSelector extends ConflictResolver.VersionSelector
A configurable version selector for use withConflictResolverthat 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 Classes Modifier and Type Class Description protected static classConfigurableVersionSelector.ConflictGroupstatic classConfigurableVersionSelector.HighestSelection strategy that selects "highest" version.static classConfigurableVersionSelector.MajorVersionConvergenceExample selection strategy (used in tests and demos), is not recommended to be used in production.static classConfigurableVersionSelector.NearestSelection strategy that selects "nearest" (to the root) version.static interfaceConfigurableVersionSelector.SelectionStrategyThe strategy how "winner" is being selected.static classConfigurableVersionSelector.VersionConvergenceExample selection strategy (used in tests and demos), is not recommended to be used in production.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCONFIG_PROP_SELECTION_STRATEGYThe name of the version selection strategy to use in conflict resolution: "nearest" (default) or "highest".static java.lang.StringDEFAULT_SELECTION_STRATEGYstatic java.lang.StringHIGHEST_SELECTION_STRATEGYstatic java.lang.StringNEAREST_SELECTION_STRATEGYprotected ConfigurableVersionSelector.SelectionStrategyselectionStrategyThe strategy of winner selection, nevernull.
-
Constructor Summary
Constructors Constructor Description ConfigurableVersionSelector()Creates 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbacktrack(ConfigurableVersionSelector.ConflictGroup group, ConflictResolver.ConflictContext context)ConflictResolver.VersionSelectorgetInstance(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(java.lang.String message, ConflictResolver.ConflictContext context)Helper method to create failure, creates instance ofUnsolvableVersionConflictException.voidselectVersion(ConflictResolver.ConflictContext context)Determines the winning node among conflicting dependencies.java.lang.StringtoString()
-
-
-
Field Detail
-
CONFIG_PROP_SELECTION_STRATEGY
public static final java.lang.String 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:
- Constant Field Values
-
NEAREST_SELECTION_STRATEGY
public static final java.lang.String NEAREST_SELECTION_STRATEGY
- See Also:
- Constant Field Values
-
HIGHEST_SELECTION_STRATEGY
public static final java.lang.String HIGHEST_SELECTION_STRATEGY
- See Also:
- Constant Field Values
-
DEFAULT_SELECTION_STRATEGY
public static final java.lang.String DEFAULT_SELECTION_STRATEGY
- See Also:
- Constant Field Values
-
selectionStrategy
protected final ConfigurableVersionSelector.SelectionStrategy selectionStrategy
The strategy of winner selection, nevernull.
-
-
Constructor Detail
-
ConfigurableVersionSelector
public ConfigurableVersionSelector()
Creates a new instance of this version selector that will use configured selection strategy dynamically.
-
ConfigurableVersionSelector
public ConfigurableVersionSelector(ConfigurableVersionSelector.SelectionStrategy selectionStrategy)
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 Detail
-
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
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
newFailure
public static org.eclipse.aether.collection.UnsolvableVersionConflictException newFailure(java.lang.String message, ConflictResolver.ConflictContext context)
Helper method to create failure, creates instance ofUnsolvableVersionConflictException.
-
-