如何获得 java_proto_library 的 1.7 兼容输出?
How can you get 1.7-compatible output for a java_proto_library?
对于 java_library
,我可以在构建规则上设置 javacopts
属性。 java_proto_library
或 java_lite_proto_library
.
似乎没有任何相似之处
我 可以 通过将 -source
和 -target
选项设置为 javac 通过 bazel 的 -javacopt
标志来解决这个问题,但是我'我宁愿将它编码在 BUILD 文件中。
您可以添加 JDK7 工具链,然后使用它构建所有内容。例如,将 this 添加到 BUILD 文件:
java_toolchain(
name = "jdk7",
bootclasspath = ["@bazel_tools//tools/jdk:bootclasspath"],
encoding = "UTF-8",
extclasspath = ["@bazel_tools//tools/jdk:extdir"],
genclass = ["@bazel_tools//tools/jdk:GenClass_deploy.jar"],
header_compiler = ["@bazel_tools//tools/jdk:turbine_deploy.jar"],
ijar = ["@bazel_tools//tools/jdk:ijar"],
javabuilder = ["@bazel_tools//tools/jdk:JavaBuilder_deploy.jar"],
javac = ["@bazel_tools//third_party/java/jdk/langtools:javac_jar"],
javac_supports_workers = 1,
jvm_opts = [
"-XX:+TieredCompilation",
"-XX:TieredStopAtLevel=1",
],
singlejar = ["@bazel_tools//tools/jdk:SingleJar_deploy.jar"],
source_version = "7",
target_version = "7",
visibility = ["//visibility:public"],
)
然后构建:
bazel build --java_toolchain=//whatever:jdk7 //your:target
对于 java_library
,我可以在构建规则上设置 javacopts
属性。 java_proto_library
或 java_lite_proto_library
.
我 可以 通过将 -source
和 -target
选项设置为 javac 通过 bazel 的 -javacopt
标志来解决这个问题,但是我'我宁愿将它编码在 BUILD 文件中。
您可以添加 JDK7 工具链,然后使用它构建所有内容。例如,将 this 添加到 BUILD 文件:
java_toolchain(
name = "jdk7",
bootclasspath = ["@bazel_tools//tools/jdk:bootclasspath"],
encoding = "UTF-8",
extclasspath = ["@bazel_tools//tools/jdk:extdir"],
genclass = ["@bazel_tools//tools/jdk:GenClass_deploy.jar"],
header_compiler = ["@bazel_tools//tools/jdk:turbine_deploy.jar"],
ijar = ["@bazel_tools//tools/jdk:ijar"],
javabuilder = ["@bazel_tools//tools/jdk:JavaBuilder_deploy.jar"],
javac = ["@bazel_tools//third_party/java/jdk/langtools:javac_jar"],
javac_supports_workers = 1,
jvm_opts = [
"-XX:+TieredCompilation",
"-XX:TieredStopAtLevel=1",
],
singlejar = ["@bazel_tools//tools/jdk:SingleJar_deploy.jar"],
source_version = "7",
target_version = "7",
visibility = ["//visibility:public"],
)
然后构建:
bazel build --java_toolchain=//whatever:jdk7 //your:target