假设我有一个最小的Scala
WORKSPACE
文件如下:
workspace(name = "scala_example")
git_repository(
name = "io_bazel_rules_scala",
commit = "e9e65ada59823c263352d10c30411f4739d5df25",
remote = "https://github.com/bazelbuild/rules_scala",
)
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")
scala_repositories()
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")
scala_register_toolchains()
然后是
BUILD
:
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_binary")
scala_binary(
name = "example-bin",
srcs = glob(["*.scala"]),
main_class = "Example",
)
和
Example.scala
:
object Example { def main(args: Array[String]): Unit = println("running") }
我可以跑步
bazel run example-bin
一切正常。我的问题是
this recent rules_scala PR
更改了Java二进制路径设置为使用以下内容的方式:
ctx.attr._java_runtime[java_common.JavaRuntimeInfo].java_executable_exec_path
而不是之前的
ctx.executable._java.short_path
。
更改后,Java二进制路径包括
external
路径中的目录,这似乎是一个遗留的东西(?)。这意味着在进行此更改后,如果我运行以下操作:
bazel run --nolegacy_external_runfiles example-bin
它不再工作:
INFO: Running command line: bazel-bin/example-bin
.../.cache/bazel/_bazel_travis/03e97e9dbbfe483081a6eca2764532e8/execroot/scala_example/bazel-out/k8-fastbuild/bin/example-bin.runfiles/scala_example/example-bin_wrapper.sh: line 4: .../.cache/bazel/_bazel_travis/03e97e9dbbfe483081a6eca2764532e8/execroot/scala_example/bazel-out/k8-fastbuild/bin/example-bin.runfiles/scala_example/external/local_jdk/bin/java: No such file or directory
ERROR: Non-zero return code '127' from command: Process exited with status 127
它还破坏了我的一些脚本-
外部的
路径。
为什么是
java_executable_exec_path
给我这个
外部的
路径我能给bazel一些选择来说服它不要这样做吗?