Skip to content

Commit 21ebd9c

Browse files
sdtwiggjohnynek
authored andcommitted
Add _jdk dependency to necessary places (#172)
The default @local_jdk just imports _java and _javac as raw binaries without establishing a dependency on/runfiles of _jdk. Thus, all uses of those should manually add _jdk as a dependency. In the scalac execution ation that compiles scala, also added _jdk in case _scalac ever was replaced by a binary that wasn't a java_binary. _jar_bin does not need a _jdk dependency since is itself a java_binary Note that earlier versions of this PR had a change to use ijars. This was reverted (although the comment referring to using ijar amended to the proper line) to keep this PR as a purely bugfix PR that should strictly increase the chance something compiles
1 parent eabdf11 commit 21ebd9c

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

scala/scala.bzl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ def _build_nosrc_jar(ctx, buildijar):
101101
if buildijar:
102102
outs.extend([ctx.outputs.ijar])
103103

104-
inputs = ctx.files.resources + [
104+
# _jdk added manually since _java doesn't currently setup runfiles
105+
inputs = ctx.files.resources + ctx.files._jdk + [
105106
ctx.outputs.manifest,
106107
ctx.executable._jar,
107108
ctx.executable._java,
@@ -207,6 +208,9 @@ SourceJars: {srcjars}
207208
outs = [ctx.outputs.jar]
208209
if buildijar:
209210
outs.extend([ctx.outputs.ijar])
211+
# _jdk added manually since _java doesn't currently setup runfiles
212+
# _scalac, as a java_binary, should already have it in its runfiles; however,
213+
# adding does ensure _java not orphaned if _scalac ever was not a java_binary
210214
ins = (list(jars) +
211215
list(dep_srcjars) +
212216
list(srcjars) +
@@ -215,6 +219,7 @@ SourceJars: {srcjars}
215219
ctx.files.plugins +
216220
ctx.files.resources +
217221
ctx.files.resource_jars +
222+
ctx.files._jdk +
218223
[ctx.outputs.manifest,
219224
ctx.executable._ijar,
220225
ctx.executable._java,
@@ -362,7 +367,7 @@ def _collect_jars(targets):
362367
# see JavaSkylarkApiProvider.java,
363368
# this is just the compile-time deps
364369
# this should be improved in bazel 0.1.5 to get outputs.ijar
365-
# compile_jars += [target.java.outputs.ijar]
370+
# compile_jars += [output.ijar for output in target.java.outputs.jars]
366371
compile_jars += target.java.transitive_deps
367372
runtime_jars += target.java.transitive_runtime_deps
368373
found = True
@@ -444,8 +449,9 @@ def _scala_binary_common(ctx, cjars, rjars):
444449
outputs = _compile_or_empty(ctx, cjars, [], False) # no need to build an ijar for an executable
445450
_build_deployable(ctx, list(rjars))
446451

452+
# _jdk added manually since _java doesn't currently setup runfiles
447453
runfiles = ctx.runfiles(
448-
files = list(rjars) + [ctx.outputs.executable],
454+
files = list(rjars) + [ctx.outputs.executable] + ctx.files._jdk,
449455
transitive_files = _get_runfiles(ctx.attr._java),
450456
collect_data = True)
451457

@@ -509,8 +515,9 @@ fi
509515
""",
510516
)
511517

518+
# _jdk added manually since _java doesn't currently setup runfiles
512519
runfiles = ctx.runfiles(
513-
files = list(rjars) + [ctx.outputs.executable],
520+
files = list(rjars) + [ctx.outputs.executable] + ctx.files._jdk,
514521
transitive_files = _get_runfiles(ctx.attr._java),
515522
collect_data = True)
516523

0 commit comments

Comments
 (0)