Bazel覆盖率需要JDK,为什么我不能使用Bazel信息提供的jdk-home?

huangapple go评论72阅读模式
英文:

Bazel coverage needs jdk, why I cannot use jdk-home given by bazel info?

问题

如果我想运行 bazel coverage,我需要添加一个规则来指定一个 jdk 工具。Bazel覆盖率运行

但为什么我不能使用 bazel 使用的 jdk,并使用 bazel info java-home 给出其路径?

为什么要加载另一个 jdk,当这个是可用的呢....??

在 WORKSPACE 中添加

load("@bazel_tools//tools/jdk:local_java_repository.bzl", "local_java_repository")

local_java_repository(
  name = "additionaljdk",          # 可以与 --java_runtime_version=additionaljdk, --java_runtime_version=11 或 --java_runtime_version=additionaljdk_11 一起使用
  version = "11",                    # 可选,如果未设置将自动检测
  java_home = "/usr/lib/jvm/java-11-openjdk-amd64/",  # 包含 bin/java 的目录路径
)

它将运行。有没有办法在前面的规则中设置一些内容,指向 $(bazel info java-home)

java_home=(locate $java-home) 

谢谢

我想避免安装另一个 jdk,因为 bazel 本身已安装。

英文:

If I want to run bazel coverage I need to add a rule to specify a jdk tool.
https://bazel.build/configure/coverage#running_coverage

But why can't I give the jdk used by bazel and for which the path is given with bazel info java-home ?

why to load another jdk when this one is avalaible.... ??

Adding in WORKSPACE

load("@bazel_tools//tools/jdk:local_java_repository.bzl", "local_java_repository")

local_java_repository(
  name = "additionaljdk",          # Can be used with --java_runtime_version=additionaljdk, --java_runtime_version=11 or --java_runtime_version=additionaljdk_11
  version = "11",                    # Optional, if not set it is autodetected
  java_home = "/usr/lib/jvm/java-11-openjdk-amd64/",  # Path to directory containing bin/java
)

it will run
is there a way to set in the previous rule something to point inside $(bazel info java-home) please ?

java_home=(locate $java-home) 

thanks

I'd like to avoid installing another jdk as it is installed by bazel itself.

答案1

得分: 1

The bazel info java-home command prints the path to the Java installation used to run Bazel itself. This Java is conceptually completely distinct from a Java that may be used by the actions that Bazel runs in a build. Bazel ships with a stripped-down, minimal JRE for itself that is not suitable for usage by build actions.

If your concern about installing a JDK is simply the inconvenience, you can use --java_runtime_version=remotejdk_11 to have Bazel pull in a JDK for you.

英文:

The bazel info java-home command prints the path to the Java installation used to run Bazel itself. This Java is conceptually completely distinct from a Java that may be used by the actions that Bazel runs in a build. Bazel ships with a stripped-down, minimal JRE for itself that is not suitable for usage by build actions.

If your concern about installing a JDK is simply the inconvenience, you can use --java_runtime_version=remotejdk_11 to have Bazel pull in a JDK for you.

huangapple
  • 本文由 发表于 2023年7月10日 22:55:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76654968.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定