diff --git a/java/BUILD b/java/BUILD index 707439f282b..4d4bd108638 100644 --- a/java/BUILD +++ b/java/BUILD @@ -64,7 +64,7 @@ java_library( "//java/com/google/devtools/intellij/blaze/plugin/aswb:__pkg__", "//java/com/google/devtools/intellij/blaze/plugin/ijwb:__pkg__", ], - deps = [":jdk_tools_jar"], + deps = ["//third_party/java/jdk:langtools"], ) # This is provided by the IDE at runtime @@ -172,12 +172,7 @@ java_binary( java_binary( name = "jdk_tools_lib", main_class = "None", - runtime_deps = [":jdk_tools_jar"], -) - -java_import( - name = "jdk_tools_jar", - jars = ["@local_jdk//:langtools"], + runtime_deps = ["//third_party/java/jdk:langtools"], ) java_binary( diff --git a/third_party/java/jdk/BUILD b/third_party/java/jdk/BUILD new file mode 100644 index 00000000000..87e28116691 --- /dev/null +++ b/third_party/java/jdk/BUILD @@ -0,0 +1,16 @@ +# Getting tools.jar from @local_jdk//:langtools is deprecated. Instead, +# copy tools.jar from @bazel_Tools//tools_jdk:current_java_runtime. +# https://github.com/bazelbuild/bazel/issues/5594 +# https://stackoverflow.com/questions/53066974/how-can-i-use-the-jar-tool-with-bazel-v0-19 +genrule( + name = "jdk_tools_jar", + outs = ["tools.jar"], + cmd = "cp $(JAVABASE)/lib/tools.jar $@", + toolchains = ["@bazel_tools//tools/jdk:current_java_runtime"], + tools = ["@bazel_tools//tools/jdk:current_java_runtime"], +) + +java_import( + name = "langtools", + jars = [":tools.jar"], +)