Skip to content

Commit 4a95548

Browse files
authored
deploy_jar creation uses args file to support long classpaths (#942)
* deploy_jar creation uses args file to support long classpaths * allow bazel to not always use param file * linting
1 parent 4833542 commit 4a95548

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

scala/private/phases/phase_merge_jars.bzl

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,27 @@ def phase_merge_jars(ctx, p):
1212
Use --compression to reduce size of deploy jars.
1313
"""
1414
deploy_jar = ctx.outputs.deploy_jar
15-
jars_list = p.compile.rjars.to_list()
15+
runtime_jars = p.compile.rjars
1616
main_class = getattr(ctx.attr, "main_class", "")
1717
progress_message = "Merging Scala jar: %s" % ctx.label
18-
args = ["--compression", "--normalize", "--sources"]
19-
args.extend([j.path for j in jars_list])
18+
args = ctx.actions.args()
19+
args.add_all(["--compression", "--normalize", "--sources"])
20+
args.add_all(runtime_jars, map_each = _fileToPath)
21+
2022
if main_class:
21-
args.extend(["--main_class", main_class])
22-
args.extend(["--output", deploy_jar.path])
23+
args.add_all(["--main_class", main_class])
24+
args.add_all(["--output", deploy_jar.path])
25+
26+
args.set_param_file_format("multiline")
27+
args.use_param_file("@%s")
2328
ctx.actions.run(
24-
inputs = jars_list,
29+
inputs = runtime_jars,
2530
outputs = [deploy_jar],
2631
executable = ctx.executable._singlejar,
2732
mnemonic = "ScalaDeployJar",
2833
progress_message = progress_message,
29-
arguments = args,
34+
arguments = [args],
3035
)
36+
37+
def _fileToPath(file):
38+
return file.path
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("//scala:scala.bzl", "scala_binary")
1+
load("//scala:scala.bzl", "scala_binary", "scala_library")
22
load(":helper.bzl", "create_dependencies", "get_dependency_labels")
33

44
scala_binary(
@@ -8,12 +8,17 @@ scala_binary(
88
unused_dependency_checker_mode = "off",
99
visibility = ["//visibility:public"],
1010
deps = get_dependency_labels(
11-
amount = 250,
11+
amount = 1000,
1212
length = 20,
1313
),
1414
)
1515

16+
scala_library(
17+
name = "triggerDeployJarCreation",
18+
data = [":largeClasspath_deploy.jar"],
19+
)
20+
1621
create_dependencies(
17-
amount = 250,
22+
amount = 1000,
1823
length = 20,
1924
)

0 commit comments

Comments
 (0)