From 7455cdc6a089daf123946a8f41a73dce543ff71f Mon Sep 17 00:00:00 2001 From: jingwen Date: Wed, 10 Jul 2019 01:30:51 -0700 Subject: [PATCH] Stop depending on deprecated @local_jdk//:langtools for tools.jar. (bazelbuild/intellij PR import #968) This removes the warning when building `//java:fast_build_javac` and `//java:jdk_tools_lib`: ``` $ bazel build //java:jdk_tools_lib //java:fast_build_javac WARNING: /Users/jingwen/code/intellij/java/BUILD:178:1: in java_import rule //java:jdk_tools_jar: target '//java:jdk_tools_jar' depends on deprecated target '@local_jdk//:langtools': Don't depend on targets in the JDK workspace; use @bazel_tools//tools/jdk:current_java_runtime instead (see https://github.com/bazelbuild/bazel/issues/5594) ``` Closes https://github.com/bazelbuild/intellij/pull/968 PiperOrigin-RevId: 257357318 --- java/BUILD | 9 ++------- third_party/java/jdk/BUILD | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 third_party/java/jdk/BUILD 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"], +)