@@ -75,13 +75,14 @@ def _compile(ctx, jars, buildijar):
7575 cmd = """
7676set -e
7777mkdir -p {out}_tmp
78- {scalac} {scala_opts} {jvm_flags} -classpath "{jars}" $@ -d {out}_tmp
78+ env JAVACMD={java} {scalac} {scala_opts} {jvm_flags} -classpath "{jars}" $@ -d {out}_tmp
7979# Make jar file deterministic by setting the timestamp of files
8080find {out}_tmp -exec touch -t 198001010000 {{}} \;
8181touch -t 198001010000 {manifest}
8282{jar} cmf {manifest} {out} -C {out}_tmp .
8383""" + ijar_cmd + res_cmd
8484 cmd = cmd .format (
85+ java = ctx .file ._java .path ,
8586 scalac = ctx .file ._scalac .path ,
8687 scala_opts = " " .join (ctx .attr .scalacopts ),
8788 jvm_flags = " " .join (["-J" + flag for flag in ctx .attr .jvm_flags ]),
@@ -257,6 +258,7 @@ _implicit_deps = {
257258 "_scalaxml" : attr .label (default = Label ("@scala//:lib/scala-xml_2.11-1.0.4.jar" ), single_file = True , allow_files = True ),
258259 "_scalasdk" : attr .label (default = Label ("@scala//:sdk" ), allow_files = True ),
259260 "_scalareflect" : attr .label (default = Label ("@scala//:lib/scala-reflect.jar" ), single_file = True , allow_files = True ),
261+ "_java" : attr .label (executable = True , default = Label ("@bazel_tools//tools/jdk:java" ), single_file = True , allow_files = True ),
260262 "_jar" : attr .label (executable = True , default = Label ("@bazel_tools//tools/jdk:jar" ), single_file = True , allow_files = True ),
261263 "_jdk" : attr .label (default = Label ("//tools/defaults:jdk" ), allow_files = True ),
262264}
@@ -302,7 +304,6 @@ scala_binary = rule(
302304 implementation = _scala_binary_impl ,
303305 attrs = {
304306 "main_class" : attr .string (mandatory = True ),
305- "_java" : attr .label (executable = True , default = Label ("@bazel_tools//tools/jdk:java" ), single_file = True , allow_files = True ),
306307 } + _implicit_deps + _common_attrs ,
307308 outputs = {
308309 "jar" : "%{name}_deploy.jar" ,
@@ -317,7 +318,6 @@ scala_test = rule(
317318 "main_class" : attr .string (default = "org.scalatest.tools.Runner" ),
318319 "suites" : attr .string_list (),
319320 "_scalatest" : attr .label (executable = True , default = Label ("@scalatest//file" ), single_file = True , allow_files = True ),
320- "_java" : attr .label (executable = True , default = Label ("@bazel_tools//tools/jdk:java" ), single_file = True , allow_files = True ),
321321 } + _implicit_deps + _common_attrs ,
322322 outputs = {
323323 "jar" : "%{name}_deploy.jar" ,
0 commit comments