Skip to content

Commit 98689d0

Browse files
authored
Propagate maven_coordinates tag to generated scala_import so pom generation includes the dependency (#1568)
* Propagate maven_coordinates tag to generated scala_import so pom generation includes the dependency * add a check for coordinates before adding tag
1 parent f4f3d9c commit 98689d0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

scala/scala_maven_import_external.bzl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def _jvm_import_external(repository_ctx):
7777
srcurls = repository_ctx.attr.srcjar_urls
7878
srcsha = repository_ctx.attr.srcjar_sha256
7979
srcpath = repository_ctx.name + "-src.jar" if srcurls else ""
80+
coordinates = repository_ctx.attr.coordinates
8081
for url in srcurls:
8182
if url.endswith(".jar"):
8283
srcpath = url[url.rindex("/") + 1:].replace("-sources.jar", "-src.jar")
@@ -97,6 +98,7 @@ def _jvm_import_external(repository_ctx):
9798
name,
9899
path,
99100
srcpath,
101+
coordinates,
100102
repository_ctx.attr,
101103
_PASS_PROPS,
102104
repository_ctx.attr.additional_rule_attrs,
@@ -110,6 +112,7 @@ def _jvm_import_external(repository_ctx):
110112
repository_ctx.attr.generated_linkable_rule_name,
111113
path,
112114
srcpath,
115+
coordinates,
113116
repository_ctx.attr,
114117
[p for p in _PASS_PROPS if p != "neverlink"],
115118
repository_ctx.attr.additional_rule_attrs,
@@ -193,6 +196,7 @@ def _serialize_given_rule_import(
193196
name,
194197
path,
195198
srcpath,
199+
coordinates,
196200
attrs,
197201
props,
198202
additional_rule_attrs):
@@ -201,6 +205,9 @@ def _serialize_given_rule_import(
201205
" name = %s," % repr(name),
202206
" jars = [%s]," % repr(path),
203207
]
208+
209+
if coordinates:
210+
lines.append(" tags = [\"maven_coordinates=%s\"]," % coordinates)
204211
if srcpath:
205212
lines.append(" srcjar = %s," % repr(srcpath))
206213
for prop in props:
@@ -240,6 +247,7 @@ jvm_import_external = repository_rule(
240247
"extra_build_file_content": attr.string(),
241248
"auth_patterns": attr.string_dict(),
242249
"netrc": attr.string(),
250+
"coordinates": attr.string(),
243251
},
244252
environ = [_FETCH_SOURCES_ENV_VAR_NAME],
245253
)
@@ -286,7 +294,7 @@ def jvm_maven_import_external(
286294

287295
srcjar_urls = _convert_coordinates_to_urls(src_coordinates, server_urls)
288296

289-
jvm_import_external(jar_urls = jar_urls, srcjar_urls = srcjar_urls, **kwargs)
297+
jvm_import_external(jar_urls = jar_urls, srcjar_urls = srcjar_urls, coordinates = artifact, **kwargs)
290298

291299
def scala_import_external(
292300
rule_load = "load(\"@io_bazel_rules_scala//scala:scala_import.bzl\", \"scala_import\")",

0 commit comments

Comments
 (0)