Skip to content

Commit

Permalink
Make java_runtime mandatory attribute of java_toolchain.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 347367273
  • Loading branch information
comius authored and copybara-github committed Dec 14, 2020
1 parent d14fcf4 commit c8e179f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,7 @@ The Java target version (e.g., '6' or '7'). It specifies for which Java runtime
.add(
attr("java_runtime", LABEL)
.cfg(ExecutionTransitionFactory.create())
// TODO(b/171140578): remove default value and set to mandatory after it is set on
// all toolchains
.value(JavaSemantics.hostJdkAttribute(env))
.mandatory()
.mandatoryProviders(ToolchainInfo.PROVIDER.id())
.allowedFileTypes(FileTypeSet.ANY_FILE)
.useOutputLicenses())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public void setupMockClient(MockToolsConfig config, List<String> workspaceConten
" singlejar = ['SingleJar_deploy.jar'],",
" genclass = ['GenClass_deploy.jar'],",
" ijar = ['ijar'],",
" java_runtime = 'host_jdk',",
")",
"java_toolchain(",
" name = 'remote_toolchain',",
Expand All @@ -143,6 +144,7 @@ public void setupMockClient(MockToolsConfig config, List<String> workspaceConten
" singlejar = ['SingleJar_deploy.jar'],",
" genclass = ['GenClass_deploy.jar'],",
" ijar = ['ijar'],",
" java_runtime = 'host_jdk',",
")",
"java_import(",
" name = 'JacocoCoverageRunner',",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@ protected void writeBuildFileForJavaToolchain() throws Exception {
" ijar = ['ijar'],",
" genclass = ['GenClass_deploy.jar'],",
" timezone_data = 'tzdata.jar',",
" java_runtime = ':jvm-k8'",
")",
"java_runtime(",
" name = 'jvm-k8',",
" srcs = [",
" 'k8/a', ",
" 'k8/b',",
" ], ",
" java_home = 'k8',",
")",
"constraint_value(",
" name = 'constraint',",
Expand Down
1 change: 1 addition & 0 deletions src/test/shell/integration/bazel_java_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ default_java_toolchain(
javabuilder = ["@bazel_tools//tools/jdk:vanillajavabuilder"],
jvm_opts = [],
visibility = ["//visibility:public"],
java_runtime = "@local_jdk//:jdk",
)
EOF

Expand Down

0 comments on commit c8e179f

Please sign in to comment.