diff --git a/private/rules/v2_lock_file.bzl b/private/rules/v2_lock_file.bzl index 886f8ac75..1e4d532fb 100644 --- a/private/rules/v2_lock_file.bzl +++ b/private/rules/v2_lock_file.bzl @@ -43,10 +43,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") @@ -104,6 +107,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 391b83aac..b57cf7cbd 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 @@ -5,10 +5,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; @@ -27,6 +32,7 @@ public Coordinates(String coordinates) { groupId = Objects.requireNonNull(parts[0]); artifactId = Objects.requireNonNull(parts[1]); + dirVersion = null; if (parts.length == 2) { extension = "jar"; @@ -48,12 +54,13 @@ 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() ? "" : classifier; this.version = version == null || version.isEmpty() ? "" : version; + this.dirVersion = dirVersion; } public String getGroupId() { @@ -64,6 +71,10 @@ public String getArtifactId() { return artifactId; } + public String getDirVersion() { + return dirVersion; + } + public String getVersion() { return version; } @@ -73,11 +84,13 @@ 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 String getExtension() { @@ -132,6 +145,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()); @@ -140,6 +154,7 @@ && getArtifactId().equals(that.getArtifactId()) @Override public int hashCode() { return Objects.hash( - getGroupId(), getArtifactId(), getVersion(), getClassifier(), getExtension()); + getGroupId(), getArtifactId(), getDirVersion(), getVersion(), getClassifier(), + getExtension()); } } 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 6643929e1..93cfaa668 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 @@ -256,21 +256,66 @@ private Map deriveCoordinateMappings(Map deriveCoordinateMappings(Map render(Set infos, Map 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 = coords.getClassifier(); if (classifier == null || classifier.isEmpty()) { diff --git a/private/tools/prebuilt/lock_file_converter_deploy.jar b/private/tools/prebuilt/lock_file_converter_deploy.jar index d8281c629..04549b9bb 100755 Binary files a/private/tools/prebuilt/lock_file_converter_deploy.jar and b/private/tools/prebuilt/lock_file_converter_deploy.jar differ