Skip to content

Commit 969f6c5

Browse files
committed
feat: Pass additional coursier cli options
1 parent d6fbf9d commit 969f6c5

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

private/rules/coursier.bzl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ def make_coursier_dep_tree(
794794
fetch_sources,
795795
fetch_javadoc,
796796
timeout,
797+
additional_options,
797798
report_progress_prefix = ""):
798799
# Set up artifact exclusion, if any. From coursier fetch --help:
799800
#
@@ -881,6 +882,8 @@ def make_coursier_dep_tree(
881882
# https://github.com/coursier/coursier/blob/1cbbf39b88ee88944a8d892789680cdb15be4714/modules/paths/src/main/java/coursier/paths/CoursierPaths.java#L29-L56
882883
environment = {"COURSIER_CACHE": str(repository_ctx.path(coursier_cache_location))}
883884

885+
cmd.extend(additional_options)
886+
884887
# Use an argsfile to avoid command line length limits, requires Java version > 8
885888
java_cmd = cmd[0]
886889
java_args = cmd[1:]
@@ -987,6 +990,7 @@ def _coursier_fetch_impl(repository_ctx):
987990
repository_ctx.attr.fetch_sources,
988991
repository_ctx.attr.fetch_javadoc,
989992
repository_ctx.attr.resolve_timeout,
993+
repository_ctx.attr.additional_options,
990994
)
991995

992996
files_to_inspect = []
@@ -1428,6 +1432,7 @@ coursier_fetch = repository_rule(
14281432
],
14291433
),
14301434
"ignore_empty_files": attr.bool(default = False, doc = "Treat jars that are empty as if they were not found."),
1435+
"additional_options": attr.string_list(doc = "Additional options that will be passed to coursier."),
14311436
},
14321437
environ = [
14331438
"JAVA_HOME",

private/rules/maven_install.bzl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def maven_install(
2727
aar_import_bzl_label = DEFAULT_AAR_IMPORT_LABEL,
2828
duplicate_version_warning = "warn",
2929
repin_instructions = None,
30-
ignore_empty_files = False):
30+
ignore_empty_files = False,
31+
resolver_additional_options = []):
3132
"""Resolves and fetches artifacts transitively from Maven repositories.
3233
3334
This macro runs a repository rule that invokes the Coursier CLI to resolve
@@ -78,6 +79,7 @@ def maven_install(
7879
is "warn".
7980
repin_instructions: Instructions to re-pin dependencies in your repository. Will be shown when re-pinning is required.
8081
ignore_empty_files: Treat jars that are empty as if they were not found.
82+
resolver_additional_options: Additional options that will be passed to the resolver. Only supports `coursier` resolver for now.
8183
"""
8284
if boms and resolver == "coursier":
8385
fail("The coursier resolver does not support resolving Maven BOMs. Please use another resolver.")
@@ -139,6 +141,7 @@ def maven_install(
139141
aar_import_bzl_label = aar_import_bzl_label,
140142
duplicate_version_warning = duplicate_version_warning,
141143
ignore_empty_files = ignore_empty_files,
144+
additional_options = resolver_additional_options,
142145
)
143146

144147
else:

0 commit comments

Comments
 (0)