diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchainRule.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchainRule.java index 06b1b9f218e328..6e0476343333ef 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchainRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchainRule.java @@ -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()) diff --git a/src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java b/src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java index 3bdbca27279c80..90cd8eba844b5c 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java @@ -130,6 +130,7 @@ public void setupMockClient(MockToolsConfig config, List workspaceConten " singlejar = ['SingleJar_deploy.jar'],", " genclass = ['GenClass_deploy.jar'],", " ijar = ['ijar'],", + " java_runtime = 'host_jdk',", ")", "java_toolchain(", " name = 'remote_toolchain',", @@ -143,6 +144,7 @@ public void setupMockClient(MockToolsConfig config, List workspaceConten " singlejar = ['SingleJar_deploy.jar'],", " genclass = ['GenClass_deploy.jar'],", " ijar = ['ijar'],", + " java_runtime = 'host_jdk',", ")", "java_import(", " name = 'JacocoCoverageRunner',", diff --git a/src/test/java/com/google/devtools/build/lib/testutil/FoundationTestCase.java b/src/test/java/com/google/devtools/build/lib/testutil/FoundationTestCase.java index 6979d3c68bb441..a8d94f3c7b286c 100644 --- a/src/test/java/com/google/devtools/build/lib/testutil/FoundationTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/testutil/FoundationTestCase.java @@ -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',", diff --git a/src/test/shell/integration/bazel_java_test.sh b/src/test/shell/integration/bazel_java_test.sh index 662a04a5efd7b9..6136cafb8afd43 100755 --- a/src/test/shell/integration/bazel_java_test.sh +++ b/src/test/shell/integration/bazel_java_test.sh @@ -181,6 +181,7 @@ default_java_toolchain( javabuilder = ["@bazel_tools//tools/jdk:vanillajavabuilder"], jvm_opts = [], visibility = ["//visibility:public"], + java_runtime = "@local_jdk//:jdk", ) EOF