I'd like to use bazel query to get more details about the Java toolchain. Specifically Java source level to be used.
From the java_library target I was able to query for the Java toolchain:
rule_input: "@bazel_tools//tools/jdk:current_java_toolchain"
rule_input: "@bazel_tools//tools/jdk:java_plugins_flag_alias"
rule_input: "@bazel_tools//tools/jdk:proguard_whitelister"
rule_input: "@bazel_tools//tools/jdk:toolchain_type"
What query can I use to get the source level the target is using?
I tried bazel query "@bazel_tools//tools/jdk:current_java_toolchain" --output=proto but the output doesn't seem to contain that information.
Your task lies fundamentally outside the capabilities of
querybecause the Java toolchain is not selected until after loading, the phasequeryoperates on. (In particular,querycannot consider--java_language_versionor other command line flags.) However,cquerycan accomplish the task:Keep in mind that a complex build could use multiple Java toolchains, leaving your inquiry ill-defined.