[jira] [Commented] (MRESOLVER-518) Improvements for version selector

2024-04-12 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MRESOLVER-518?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17836460#comment-17836460
 ] 

ASF GitHub Bot commented on MRESOLVER-518:
--

cstamas merged PR #450:
URL: https://github.com/apache/maven-resolver/pull/450




> Improvements for version selector
> -
>
> Key: MRESOLVER-518
> URL: https://issues.apache.org/jira/browse/MRESOLVER-518
> Project: Maven Resolver
>  Issue Type: New Feature
>  Components: Resolver
>Reporter: Tamas Cservenak
>Assignee: Tamas Cservenak
>Priority: Major
> Fix For: 2.0.0, 2.0.0-alpha-11
>
>
> Currently Resolver "silently" resolves conflict based on "nearest" strategy, 
> without any assumption about selected version (simply the fact it is "nearer 
> to root" makes it win).
> Extend this logic by ability to fail collection in case of version conflict, 
> version divergence and "version incompatibility" for start. As it may come 
> handy, and user may want to fix the build differently than Maven would.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MRESOLVER-518) Improvements for version selector

2024-04-08 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MRESOLVER-518?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17834869#comment-17834869
 ] 

ASF GitHub Bot commented on MRESOLVER-518:
--

cstamas commented on PR #450:
URL: https://github.com/apache/maven-resolver/pull/450#issuecomment-2042356577

   ping, any other comments to this PR?




> Improvements for version selector
> -
>
> Key: MRESOLVER-518
> URL: https://issues.apache.org/jira/browse/MRESOLVER-518
> Project: Maven Resolver
>  Issue Type: New Feature
>  Components: Resolver
>Reporter: Tamas Cservenak
>Assignee: Tamas Cservenak
>Priority: Major
> Fix For: 2.0.0, 2.0.0-alpha-11
>
>
> Currently Resolver "silently" resolves conflict based on "nearest" strategy, 
> without any assumption about selected version (simply the fact it is "nearer 
> to root" makes it win).
> Extend this logic by ability to fail collection in case of version conflict, 
> version divergence and "version incompatibility" for start. As it may come 
> handy, and user may want to fix the build differently than Maven would.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MRESOLVER-518) Improvements for version selector

2024-04-03 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MRESOLVER-518?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17833491#comment-17833491
 ] 

ASF GitHub Bot commented on MRESOLVER-518:
--

cstamas commented on code in PR #450:
URL: https://github.com/apache/maven-resolver/pull/450#discussion_r1549450171


##
maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/ConfigurableVersionSelector.java:
##
@@ -0,0 +1,350 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.eclipse.aether.util.graph.transformer;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.eclipse.aether.RepositoryException;
+import org.eclipse.aether.collection.UnsolvableVersionConflictException;
+import org.eclipse.aether.graph.DependencyFilter;
+import org.eclipse.aether.graph.DependencyNode;
+import 
org.eclipse.aether.util.graph.transformer.ConflictResolver.ConflictContext;
+import org.eclipse.aether.util.graph.transformer.ConflictResolver.ConflictItem;
+import 
org.eclipse.aether.util.graph.transformer.ConflictResolver.VersionSelector;
+import org.eclipse.aether.util.graph.visitor.PathRecordingDependencyVisitor;
+import org.eclipse.aether.util.graph.visitor.TreeDependencyVisitor;
+import org.eclipse.aether.version.Version;
+import org.eclipse.aether.version.VersionConstraint;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * A configurable version selector for use with {@link 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
+ */
+public class ConfigurableVersionSelector extends VersionSelector {
+/**
+ * The strategy how "winner" is being selected.
+ */
+public enum SelectionStrategy {
+/**
+ * This is how Maven3 works, chooses "nearer" dependency for winner.
+ */
+NEARER,
+/**
+ * This is new mode, chooses "higher version" dependency for winner.
+ */
+HIGHER_VERSION;
+}
+/**
+ * The compatibility check strategy.
+ */
+public interface CompatibilityStrategy {
+/**
+ * This method should determine are versions of two items "compatible" 
or not. This method is invoked whenever
+ * {@code candidate} is "considered" (does not have to be selected as 
"winner").
+ */
+boolean isIncompatibleVersion(ConflictItem candidate, ConflictItem 
winner)
+throws UnsolvableVersionConflictException;
+}
+/**
+ * If true, this version selector will fail if detects "dependency version 
divergence" in graph.
+ */
+protected final boolean enforceVersionConvergence;

Review Comment:
   Agreed, is a strategy now.





> Improvements for version selector
> -
>
> Key: MRESOLVER-518
> URL: https://issues.apache.org/jira/browse/MRESOLVER-518
> Project: Maven Resolver
>  Issue Type: New Feature
>  Components: Resolver
>Reporter: Tamas Cservenak
>Assignee: Tamas Cservenak
>Priority: Major
> Fix For: 2.0.0, 2.0.0-alpha-11
>
>
> Currently Resolver "silently" resolves conflict based on "nearest" strategy, 
> without any assumption about selected version (simply the fact it is "nearer 
> to root" makes it win).
> Extend this logic by ability to fail collection in case of version conflict, 
> version divergence and "version incompatibility" for start. As it may come 
> handy, and user may want to fix the build differently than Maven would.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MRESOLVER-518) Improvements for version selector

2024-04-03 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MRESOLVER-518?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17833483#comment-17833483
 ] 

ASF GitHub Bot commented on MRESOLVER-518:
--

cstamas commented on code in PR #450:
URL: https://github.com/apache/maven-resolver/pull/450#discussion_r1549407294


##
maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/NearestVersionSelector.java:
##
@@ -126,7 +129,7 @@ private UnsolvableVersionConflictException newFailure(final 
ConflictContext cont
 };
 PathRecordingDependencyVisitor visitor = new 
PathRecordingDependencyVisitor(filter);
 context.getRoot().accept(new TreeDependencyVisitor(visitor));
-return new UnsolvableVersionConflictException(visitor.getPaths());
+return new UnsolvableVersionConflictException(null, 
visitor.getPaths());

Review Comment:
   undone





> Improvements for version selector
> -
>
> Key: MRESOLVER-518
> URL: https://issues.apache.org/jira/browse/MRESOLVER-518
> Project: Maven Resolver
>  Issue Type: New Feature
>  Components: Resolver
>Reporter: Tamas Cservenak
>Assignee: Tamas Cservenak
>Priority: Major
> Fix For: 2.0.0, 2.0.0-alpha-11
>
>
> Currently Resolver "silently" resolves conflict based on "nearest" strategy, 
> without any assumption about selected version (simply the fact it is "nearer 
> to root" makes it win).
> Extend this logic by ability to fail collection in case of version conflict, 
> version divergence and "version incompatibility" for start. As it may come 
> handy, and user may want to fix the build differently than Maven would.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MRESOLVER-518) Improvements for version selector

2024-04-03 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MRESOLVER-518?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17833477#comment-17833477
 ] 

ASF GitHub Bot commented on MRESOLVER-518:
--

cstamas commented on code in PR #450:
URL: https://github.com/apache/maven-resolver/pull/450#discussion_r1549387693


##
maven-resolver-api/src/main/java/org/eclipse/aether/collection/UnsolvableVersionConflictException.java:
##
@@ -42,9 +42,25 @@ public class UnsolvableVersionConflictException extends 
RepositoryException {
  * Creates a new exception with the specified paths to conflicting nodes 
in the dependency graph.
  *
  * @param paths The paths to the dependency nodes that participate in the 
version conflict, may be {@code null}.
+ * @deprecated Use {@link #UnsolvableVersionConflictException(String, 
Collection)} instead.

Review Comment:
   No existing code uses this deprecated ctor (not counting deprecated class), 
or new one with `null` param, it is left merely for binary compatibility. In 
fact, this exception is so special, that nothing else uses it.





> Improvements for version selector
> -
>
> Key: MRESOLVER-518
> URL: https://issues.apache.org/jira/browse/MRESOLVER-518
> Project: Maven Resolver
>  Issue Type: New Feature
>  Components: Resolver
>Reporter: Tamas Cservenak
>Assignee: Tamas Cservenak
>Priority: Major
> Fix For: 2.0.0, 2.0.0-alpha-11
>
>
> Currently Resolver "silently" resolves conflict based on "nearest" strategy, 
> without any assumption about selected version (simply the fact it is "nearer 
> to root" makes it win).
> Extend this logic by ability to fail collection in case of version conflict, 
> version divergence and "version incompatibility" for start. As it may come 
> handy, and user may want to fix the build differently than Maven would.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MRESOLVER-518) Improvements for version selector

2024-04-03 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MRESOLVER-518?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17833476#comment-17833476
 ] 

ASF GitHub Bot commented on MRESOLVER-518:
--

gnodet commented on code in PR #450:
URL: https://github.com/apache/maven-resolver/pull/450#discussion_r1549385293


##
maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/ConfigurableVersionSelector.java:
##
@@ -0,0 +1,350 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.eclipse.aether.util.graph.transformer;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.eclipse.aether.RepositoryException;
+import org.eclipse.aether.collection.UnsolvableVersionConflictException;
+import org.eclipse.aether.graph.DependencyFilter;
+import org.eclipse.aether.graph.DependencyNode;
+import 
org.eclipse.aether.util.graph.transformer.ConflictResolver.ConflictContext;
+import org.eclipse.aether.util.graph.transformer.ConflictResolver.ConflictItem;
+import 
org.eclipse.aether.util.graph.transformer.ConflictResolver.VersionSelector;
+import org.eclipse.aether.util.graph.visitor.PathRecordingDependencyVisitor;
+import org.eclipse.aether.util.graph.visitor.TreeDependencyVisitor;
+import org.eclipse.aether.version.Version;
+import org.eclipse.aether.version.VersionConstraint;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * A configurable version selector for use with {@link 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
+ */
+public class ConfigurableVersionSelector extends VersionSelector {
+/**
+ * The strategy how "winner" is being selected.
+ */
+public enum SelectionStrategy {
+/**
+ * This is how Maven3 works, chooses "nearer" dependency for winner.
+ */
+NEARER,
+/**
+ * This is new mode, chooses "higher version" dependency for winner.
+ */
+HIGHER_VERSION;
+}
+/**
+ * The compatibility check strategy.
+ */
+public interface CompatibilityStrategy {
+/**
+ * This method should determine are versions of two items "compatible" 
or not. This method is invoked whenever
+ * {@code candidate} is "considered" (does not have to be selected as 
"winner").
+ */
+boolean isIncompatibleVersion(ConflictItem candidate, ConflictItem 
winner)
+throws UnsolvableVersionConflictException;
+}
+/**
+ * If true, this version selector will fail if detects "dependency version 
divergence" in graph.
+ */
+protected final boolean enforceVersionConvergence;

Review Comment:
   Should that be a specific selection strategy instead ?
   We can't really enforce a single version and select the higher (or nearer) 
at the same time, right ?





> Improvements for version selector
> -
>
> Key: MRESOLVER-518
> URL: https://issues.apache.org/jira/browse/MRESOLVER-518
> Project: Maven Resolver
>  Issue Type: New Feature
>  Components: Resolver
>Reporter: Tamas Cservenak
>Assignee: Tamas Cservenak
>Priority: Major
> Fix For: 2.0.0, 2.0.0-alpha-11
>
>
> Currently Resolver "silently" resolves conflict based on "nearest" strategy, 
> without any assumption about selected version (simply the fact it is "nearer 
> to root" makes it win).
> Extend this logic by ability to fail collection in case of version conflict, 
> version divergence and "version incompatibility" for start. As it may come 
> handy, and user may want to fix the build differently than Maven would.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MRESOLVER-518) Improvements for version selector

2024-04-03 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MRESOLVER-518?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17833474#comment-17833474
 ] 

ASF GitHub Bot commented on MRESOLVER-518:
--

gnodet commented on code in PR #450:
URL: https://github.com/apache/maven-resolver/pull/450#discussion_r1549378256


##
maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/NearestVersionSelector.java:
##
@@ -126,7 +129,7 @@ private UnsolvableVersionConflictException newFailure(final 
ConflictContext cont
 };
 PathRecordingDependencyVisitor visitor = new 
PathRecordingDependencyVisitor(filter);
 context.getRoot().accept(new TreeDependencyVisitor(visitor));
-return new UnsolvableVersionConflictException(visitor.getPaths());
+return new UnsolvableVersionConflictException(null, 
visitor.getPaths());

Review Comment:
   No need for this change imho





> Improvements for version selector
> -
>
> Key: MRESOLVER-518
> URL: https://issues.apache.org/jira/browse/MRESOLVER-518
> Project: Maven Resolver
>  Issue Type: New Feature
>  Components: Resolver
>Reporter: Tamas Cservenak
>Assignee: Tamas Cservenak
>Priority: Major
> Fix For: 2.0.0, 2.0.0-alpha-11
>
>
> Currently Resolver "silently" resolves conflict based on "nearest" strategy, 
> without any assumption about selected version (simply the fact it is "nearer 
> to root" makes it win).
> Extend this logic by ability to fail collection in case of version conflict, 
> version divergence and "version incompatibility" for start. As it may come 
> handy, and user may want to fix the build differently than Maven would.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (MRESOLVER-518) Improvements for version selector

2024-04-03 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/MRESOLVER-518?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17833473#comment-17833473
 ] 

ASF GitHub Bot commented on MRESOLVER-518:
--

gnodet commented on code in PR #450:
URL: https://github.com/apache/maven-resolver/pull/450#discussion_r1549377629


##
maven-resolver-api/src/main/java/org/eclipse/aether/collection/UnsolvableVersionConflictException.java:
##
@@ -42,9 +42,25 @@ public class UnsolvableVersionConflictException extends 
RepositoryException {
  * Creates a new exception with the specified paths to conflicting nodes 
in the dependency graph.
  *
  * @param paths The paths to the dependency nodes that participate in the 
version conflict, may be {@code null}.
+ * @deprecated Use {@link #UnsolvableVersionConflictException(String, 
Collection)} instead.

Review Comment:
   I don't see the point of deprecating this constructor, since it forces the 
addition of a `null` parameter and lead the user to a change which is useless, 
given the message has a default value.





> Improvements for version selector
> -
>
> Key: MRESOLVER-518
> URL: https://issues.apache.org/jira/browse/MRESOLVER-518
> Project: Maven Resolver
>  Issue Type: New Feature
>  Components: Resolver
>Reporter: Tamas Cservenak
>Assignee: Tamas Cservenak
>Priority: Major
> Fix For: 2.0.0, 2.0.0-alpha-11
>
>
> Currently Resolver "silently" resolves conflict based on "nearest" strategy, 
> without any assumption about selected version (simply the fact it is "nearer 
> to root" makes it win).
> Extend this logic by ability to fail collection in case of version conflict, 
> version divergence and "version incompatibility" for start. As it may come 
> handy, and user may want to fix the build differently than Maven would.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)