Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Deduplicate deps while amending #1266

Merged
merged 4 commits into from
Nov 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions private/rules/coursier.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,8 @@ def rewrite_files_attribute_if_necessary(repository_ctx, dep_tree):
# `pinned_maven_install`. Oh well, let's just do this the manual way.
if dep["file"].endswith(".pom"):
jar_path = dep["file"].removesuffix(".pom") + ".jar"
if is_dep(jar_path, amended_deps):
continue
if repository_ctx.path(jar_path).exists:
dep["file"] = jar_path

Expand All @@ -963,6 +965,12 @@ def rewrite_files_attribute_if_necessary(repository_ctx, dep_tree):

return dep_tree

def is_dep(jar_path, deps):
jin marked this conversation as resolved.
Show resolved Hide resolved
for dep in reversed(deps):
jin marked this conversation as resolved.
Show resolved Hide resolved
if jar_path == dep.get("file", None):
return True
return False

def remove_prefix(s, prefix):
if s.startswith(prefix):
return s[len(prefix):]
Expand Down