You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "cstamas (via GitHub)" <gi...@apache.org> on 2024/01/17 09:24:07 UTC
[PR] [MRESOLVER-465] Make room for alternate version scheme [maven-resolver]
cstamas opened a new pull request, #407:
URL: https://github.com/apache/maven-resolver/pull/407
Since eons Resolver had the "generic" scheme implementing the `Version`, `VersionRange` and `VersionConstraint` API interfaces.
Interesting fact: `GenericVersionRange` and `GenericVersionConstraint` are NOT tied in any way to `GenericVersion` implementation, they are happy with plain `Version` interface as well, they are truly "generic".
This means, that a scheme needs really only to provide `Version` implementation (currently in form of `GenericVersion`) and a "factory" for it (currently in a form of `GenericVersionScheme`).
Refactor a bit, and make room for alternate Version implementations.
Fact: the change can be done in source and binary compatible way, and is enforced by japicmp.
---
https://issues.apache.org/jira/browse/MRESOLVER-465
--
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-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MRESOLVER-465] Make room for alternate version scheme [maven-resolver]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on PR #407:
URL: https://github.com/apache/maven-resolver/pull/407#issuecomment-1895722253
@gnodet agreed with all, but _I did not change any of these_, all I did is split the class (support + generic scheme). The idea is to have new version scheme provided by Resolver in this very same package (not by "third party" as that would open up a can of worms).
--
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-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MRESOLVER-465] Make room for alternate version scheme [maven-resolver]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on PR #407:
URL: https://github.com/apache/maven-resolver/pull/407#issuecomment-1895829404
> Oh, yes, true, oversight on my part. Fixed
Much better now. Do we need to keep the hashCode / equals on version scheme ? They really look weird on a pure service class.
--
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-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MRESOLVER-465] Make room for alternate version scheme [maven-resolver]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on PR #407:
URL: https://github.com/apache/maven-resolver/pull/407#issuecomment-1895916360
Removed them.
--
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-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MRESOLVER-465] Make room for alternate version scheme [maven-resolver]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas merged PR #407:
URL: https://github.com/apache/maven-resolver/pull/407
--
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-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MRESOLVER-465] Make room for alternate version scheme [maven-resolver]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #407:
URL: https://github.com/apache/maven-resolver/pull/407#discussion_r1455436530
##########
maven-resolver-util/src/main/java/org/eclipse/aether/util/version/GenericVersionConstraint.java:
##########
@@ -28,6 +28,8 @@
/**
* A constraint on versions for a dependency.
+ * <p>
+ * Despite its name, this class is generic in a sense it works with any {@link Version}.
Review Comment:
Who cares if the classes are protected and final ?
This only makes sense if these implementation classes are made `public`.
##########
maven-resolver-util/src/main/java/org/eclipse/aether/util/version/VersionSchemeSupport.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.version;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.aether.version.InvalidVersionSpecificationException;
+import org.eclipse.aether.version.VersionRange;
+import org.eclipse.aether.version.VersionScheme;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * A version scheme support class. A new implementation should extend this class and would receive full support for
+ * ranges and constraints. The new implementation should implement {@link org.eclipse.aether.version.Version} and
+ * the one missing method in this class, the {@link #parseVersion(String)}.
+ *
+ * @since 2.0.0
+ */
+public abstract class VersionSchemeSupport implements VersionScheme {
+ @Override
+ public GenericVersionRange parseVersionRange(final String range) throws InvalidVersionSpecificationException {
+ return new GenericVersionRange(this, range);
+ }
+
+ @Override
+ public GenericVersionConstraint parseVersionConstraint(final String constraint)
+ throws InvalidVersionSpecificationException {
+ String process = requireNonNull(constraint, "constraint cannot be null");
+
+ Collection<VersionRange> ranges = new ArrayList<>();
+
+ while (process.startsWith("[") || process.startsWith("(")) {
+ int index1 = process.indexOf(')');
+ int index2 = process.indexOf(']');
+
+ int index = index2;
+ if (index2 < 0 || (index1 >= 0 && index1 < index2)) {
+ index = index1;
+ }
+
+ if (index < 0) {
+ throw new InvalidVersionSpecificationException(constraint, "Unbounded version range " + constraint);
+ }
+
+ VersionRange range = parseVersionRange(process.substring(0, index + 1));
+ ranges.add(range);
+
+ process = process.substring(index + 1).trim();
+
+ if (process.startsWith(",")) {
+ process = process.substring(1).trim();
+ }
+ }
+
+ if (!process.isEmpty() && !ranges.isEmpty()) {
+ throw new InvalidVersionSpecificationException(
+ constraint, "Invalid version range " + constraint + ", expected [ or ( but got " + process);
+ }
+
+ GenericVersionConstraint result;
+ if (ranges.isEmpty()) {
+ result = new GenericVersionConstraint(parseVersion(constraint));
+ } else {
+ result = new GenericVersionConstraint(UnionVersionRange.from(ranges));
+ }
+
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ return obj != null && getClass().equals(obj.getClass());
+ }
+
+ @Override
+ public int hashCode() {
Review Comment:
Useless
##########
maven-resolver-util/src/main/java/org/eclipse/aether/util/version/VersionSchemeSupport.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.version;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.aether.version.InvalidVersionSpecificationException;
+import org.eclipse.aether.version.VersionRange;
+import org.eclipse.aether.version.VersionScheme;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * A version scheme support class. A new implementation should extend this class and would receive full support for
+ * ranges and constraints. The new implementation should implement {@link org.eclipse.aether.version.Version} and
+ * the one missing method in this class, the {@link #parseVersion(String)}.
+ *
+ * @since 2.0.0
+ */
+public abstract class VersionSchemeSupport implements VersionScheme {
+ @Override
+ public GenericVersionRange parseVersionRange(final String range) throws InvalidVersionSpecificationException {
+ return new GenericVersionRange(this, range);
+ }
+
+ @Override
+ public GenericVersionConstraint parseVersionConstraint(final String constraint)
Review Comment:
Same.
This should even cause a warning as `GenericVersionConstraint` is exported outside it's visibility.
##########
maven-resolver-util/src/main/java/org/eclipse/aether/util/version/GenericVersionRange.java:
##########
@@ -23,13 +23,17 @@
import org.eclipse.aether.version.InvalidVersionSpecificationException;
import org.eclipse.aether.version.Version;
import org.eclipse.aether.version.VersionRange;
+import org.eclipse.aether.version.VersionScheme;
import static java.util.Objects.requireNonNull;
/**
* A version range inspired by mathematical range syntax. For example, "[1.0,2.0)", "[1.0,)" or "[1.0]".
+ * <p>
+ * Despite its name, this class is generic in a sense it works with any {@link Version}
Review Comment:
Same
##########
maven-resolver-util/src/main/java/org/eclipse/aether/util/version/VersionSchemeSupport.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.version;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.aether.version.InvalidVersionSpecificationException;
+import org.eclipse.aether.version.VersionRange;
+import org.eclipse.aether.version.VersionScheme;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * A version scheme support class. A new implementation should extend this class and would receive full support for
+ * ranges and constraints. The new implementation should implement {@link org.eclipse.aether.version.Version} and
+ * the one missing method in this class, the {@link #parseVersion(String)}.
+ *
+ * @since 2.0.0
+ */
+public abstract class VersionSchemeSupport implements VersionScheme {
+ @Override
+ public GenericVersionRange parseVersionRange(final String range) throws InvalidVersionSpecificationException {
+ return new GenericVersionRange(this, range);
+ }
+
+ @Override
+ public GenericVersionConstraint parseVersionConstraint(final String constraint)
+ throws InvalidVersionSpecificationException {
+ String process = requireNonNull(constraint, "constraint cannot be null");
+
+ Collection<VersionRange> ranges = new ArrayList<>();
+
+ while (process.startsWith("[") || process.startsWith("(")) {
+ int index1 = process.indexOf(')');
+ int index2 = process.indexOf(']');
+
+ int index = index2;
+ if (index2 < 0 || (index1 >= 0 && index1 < index2)) {
+ index = index1;
+ }
+
+ if (index < 0) {
+ throw new InvalidVersionSpecificationException(constraint, "Unbounded version range " + constraint);
+ }
+
+ VersionRange range = parseVersionRange(process.substring(0, index + 1));
+ ranges.add(range);
+
+ process = process.substring(index + 1).trim();
+
+ if (process.startsWith(",")) {
+ process = process.substring(1).trim();
+ }
+ }
+
+ if (!process.isEmpty() && !ranges.isEmpty()) {
+ throw new InvalidVersionSpecificationException(
+ constraint, "Invalid version range " + constraint + ", expected [ or ( but got " + process);
+ }
+
+ GenericVersionConstraint result;
+ if (ranges.isEmpty()) {
+ result = new GenericVersionConstraint(parseVersion(constraint));
+ } else {
+ result = new GenericVersionConstraint(UnionVersionRange.from(ranges));
+ }
+
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
Review Comment:
Does it make sense at all ? This isn't a data object. If there's a need, they should be identified by a name 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-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MRESOLVER-465] Make room for alternate version scheme [maven-resolver]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on PR #407:
URL: https://github.com/apache/maven-resolver/pull/407#issuecomment-1895725220
> @gnodet agreed with all, but _I did not change any of these_, all I did is split the class (support + generic scheme). The idea is to have new version scheme provided by Resolver in this very same package (not by "third party" as that would open up a can of worms).
Then `VersionSchemeSupport` should not be public. That will remove almost all those problems.
--
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-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MRESOLVER-465] Make room for alternate version scheme [maven-resolver]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on PR #407:
URL: https://github.com/apache/maven-resolver/pull/407#issuecomment-1895736927
Oh, yes, true, oversight on my part. Fixed
--
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-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org