Skip to content

Commit

Permalink
Stop depending on deprecated @local_jdk//:langtools for tools.jar. (b…
Browse files Browse the repository at this point in the history
…azelbuild/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 bazelbuild/bazel#5594)
```

Closes #968

PiperOrigin-RevId: 257357318
  • Loading branch information
jin authored and copybara-github committed Jul 10, 2019
1 parent 13bcd8d commit ef6bd5f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
9 changes: 2 additions & 7 deletions java/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
16 changes: 16 additions & 0 deletions third_party/java/jdk/BUILD
Original file line number Diff line number Diff line change
@@ -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"],
)

0 comments on commit ef6bd5f

Please sign in to comment.