Re: [PR] [MRESOLVER-518] Version selector improvements [maven-resolver]

2024-04-12 Thread via GitHub


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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [MRESOLVER-518] Version selector improvements [maven-resolver]

2024-04-08 Thread via GitHub


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

   ping, any other comments to this PR?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [MRESOLVER-518] Version selector improvements [maven-resolver]

2024-04-03 Thread via GitHub


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.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [MRESOLVER-518] Version selector improvements [maven-resolver]

2024-04-03 Thread via GitHub


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



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [MRESOLVER-518] Version selector improvements [maven-resolver]

2024-04-03 Thread via GitHub


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.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [MRESOLVER-518] Version selector improvements [maven-resolver]

2024-04-03 Thread via GitHub


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 ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [MRESOLVER-518] Version selector improvements [maven-resolver]

2024-04-03 Thread via GitHub


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



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [MRESOLVER-518] Version selector improvements [maven-resolver]

2024-04-03 Thread via GitHub


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.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org