diff --git a/private/rules/v2_lock_file.bzl b/private/rules/v2_lock_file.bzl index bc966ab0e..b6938dc19 100644 --- a/private/rules/v2_lock_file.bzl +++ b/private/rules/v2_lock_file.bzl @@ -46,10 +46,13 @@ def _compute_lock_file_hash(lock_file_contents): return hash(repr(to_hash)) def _to_m2_path(unpacked): - path = "{group}/{artifact}/{version}/{artifact}-{version}".format( + version = unpacked["version"] + dir_version = getattr(unpacked, "dirVersion", version) + path = "{group}/{artifact}/{dir_version}/{artifact}-{version}".format( artifact = unpacked["artifactId"], group = unpacked["groupId"].replace(".", "/"), - version = unpacked["version"], + version = version, + dir_version = dir_version, ) classifier = unpacked.get("scope", "jar") @@ -108,6 +111,8 @@ def _get_artifacts(lock_file_contents): "artifactId": parts[1], "version": data["version"], } + if "dirVersion" in data: + root_unpacked["dirVersion"] = data["dirVersion"] if len(parts) > 2: root_unpacked["type"] = parts[2] else: diff --git a/private/tools/java/com/github/bazelbuild/rules_jvm_external/Coordinates.java b/private/tools/java/com/github/bazelbuild/rules_jvm_external/Coordinates.java index c1f6ff5ce..0bf7294d1 100644 --- a/private/tools/java/com/github/bazelbuild/rules_jvm_external/Coordinates.java +++ b/private/tools/java/com/github/bazelbuild/rules_jvm_external/Coordinates.java @@ -19,10 +19,15 @@ /** * Represents a Maven coordinate using Maven's standard schema of * :[:[:][:]. + * + *

The optional dirVersion property is used for snapshotted artifacts. For those, + * directory version component in the repository URL is of the *-SNAPSHOT * form + * whereas the version in the artifact itself numeric.

*/ public class Coordinates implements Comparable { private final String groupId; private final String artifactId; + private final String dirVersion; private final String version; private final String classifier; private final String extension; @@ -41,6 +46,7 @@ public Coordinates(String coordinates) { groupId = Objects.requireNonNull(parts[0]); artifactId = Objects.requireNonNull(parts[1]); + dirVersion = null; if (parts.length == 2) { extension = "jar"; @@ -62,13 +68,14 @@ public Coordinates(String coordinates) { } public Coordinates( - String groupId, String artifactId, String extension, String classifier, String version) { + String groupId, String artifactId, String extension, String classifier, String version, String dirVersion) { this.groupId = Objects.requireNonNull(groupId, "Group ID"); this.artifactId = Objects.requireNonNull(artifactId, "Artifact ID"); this.extension = extension == null || extension.isEmpty() ? "jar" : extension; this.classifier = classifier == null || classifier.isEmpty() || "jar".equals(classifier) ? "" : classifier; this.version = version == null || version.isEmpty() ? "" : version; + this.dirVersion = dirVersion; } public String getGroupId() { @@ -79,6 +86,10 @@ public String getArtifactId() { return artifactId; } + public String getDirVersion() { + return dirVersion; + } + public String getVersion() { return version; } @@ -88,15 +99,17 @@ public String getClassifier() { } public Coordinates setClassifier(String classifier) { - return new Coordinates(getGroupId(), getArtifactId(), getExtension(), classifier, getVersion()); + return new Coordinates( + getGroupId(), getArtifactId(), getExtension(), classifier, getVersion(), getDirVersion()); } public Coordinates setExtension(String extension) { - return new Coordinates(getGroupId(), getArtifactId(), extension, getClassifier(), getVersion()); + return new Coordinates( + getGroupId(), getArtifactId(), extension, getClassifier(), getVersion(), getDirVersion()); } public Coordinates setVersion(String version) { - return new Coordinates(getGroupId(), getArtifactId(), getExtension(), getClassifier(), version); + return new Coordinates(getGroupId(), getArtifactId(), getExtension(), getClassifier(), version, getDirVersion()); } public String getExtension() { @@ -177,6 +190,7 @@ public boolean equals(Object o) { Coordinates that = (Coordinates) o; return getGroupId().equals(that.getGroupId()) && getArtifactId().equals(that.getArtifactId()) + && Objects.equals(getDirVersion(), that.getDirVersion()) && Objects.equals(getVersion(), that.getVersion()) && Objects.equals(getClassifier(), that.getClassifier()) && Objects.equals(getExtension(), that.getExtension()); @@ -185,7 +199,8 @@ && getArtifactId().equals(that.getArtifactId()) @Override public int hashCode() { return Objects.hash( - getGroupId(), getArtifactId(), getVersion(), getClassifier(), getExtension()); + getGroupId(), getArtifactId(), getDirVersion(), getVersion(), getClassifier(), + getExtension()); } private boolean isNullOrEmpty(String value) { diff --git a/private/tools/java/com/github/bazelbuild/rules_jvm_external/coursier/LockFileConverter.java b/private/tools/java/com/github/bazelbuild/rules_jvm_external/coursier/LockFileConverter.java index 20a729ccb..9fa392048 100644 --- a/private/tools/java/com/github/bazelbuild/rules_jvm_external/coursier/LockFileConverter.java +++ b/private/tools/java/com/github/bazelbuild/rules_jvm_external/coursier/LockFileConverter.java @@ -275,21 +275,66 @@ private Map deriveCoordinateMappings(Map deriveCoordinateMappings(Map render( Map artifactValue = artifacts.computeIfAbsent(shortKey, k -> new TreeMap<>()); artifactValue.put("version", coords.getVersion()); + String dirVersion = coords.getDirVersion(); + if (dirVersion != null) { + artifactValue.put("dirVersion", coords.getDirVersion()); + } String classifier; if (coords.getClassifier() == null || coords.getClassifier().isEmpty()) { diff --git a/private/tools/java/com/github/bazelbuild/rules_jvm_external/resolver/ResolutionRequest.java b/private/tools/java/com/github/bazelbuild/rules_jvm_external/resolver/ResolutionRequest.java index 3185d5b1c..85006b8e1 100644 --- a/private/tools/java/com/github/bazelbuild/rules_jvm_external/resolver/ResolutionRequest.java +++ b/private/tools/java/com/github/bazelbuild/rules_jvm_external/resolver/ResolutionRequest.java @@ -73,7 +73,8 @@ public ResolutionRequest addBom(Coordinates coordinates, String... exclusions) { coordinates.getArtifactId(), "pom", "", - coordinates.getVersion()); + coordinates.getVersion(), + coordinates.getDirVersion()); Artifact artifact = new Artifact(bom, Stream.of(exclusions).map(Coordinates::new).collect(Collectors.toSet())); diff --git a/private/tools/prebuilt/index_jar_deploy.jar b/private/tools/prebuilt/index_jar_deploy.jar index 9407dd8b9..c09b78b85 100755 Binary files a/private/tools/prebuilt/index_jar_deploy.jar and b/private/tools/prebuilt/index_jar_deploy.jar differ diff --git a/private/tools/prebuilt/lock_file_converter_deploy.jar b/private/tools/prebuilt/lock_file_converter_deploy.jar index 6b8009291..ec779d45f 100755 Binary files a/private/tools/prebuilt/lock_file_converter_deploy.jar and b/private/tools/prebuilt/lock_file_converter_deploy.jar differ diff --git a/private/tools/prebuilt/outdated_deploy.jar b/private/tools/prebuilt/outdated_deploy.jar index fafde6b54..cc93a62fd 100755 Binary files a/private/tools/prebuilt/outdated_deploy.jar and b/private/tools/prebuilt/outdated_deploy.jar differ