From 3ed0112115c50866c78bb425271d7153b266f00c Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Tue, 14 Aug 2018 08:10:37 +0200 Subject: [PATCH] Bazel: Fix eclipse classpath generation Since I819954da56 JUnit test is added that depends on reviewdb_proto, however, this new dependency wasn't added to Eclipse classpath generation machinery. Widen the visibility of that library and add it to the transitive closure of Eclipse classpath generation. Ad a side effect, we need to conditionally query compilation_info attribute during classpath generation, because java_proto_library doesn't expose this attribute. Bug: Issue 9564 Change-Id: I4ef1be9b1f7db9764f6bc8e5571da6ba6ac211f6 --- proto/BUILD | 5 ++++- tools/bzl/classpath.bzl | 3 ++- tools/eclipse/BUILD | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/proto/BUILD b/proto/BUILD index 0578ca577c..00d725aa8b 100644 --- a/proto/BUILD +++ b/proto/BUILD @@ -23,6 +23,9 @@ proto_library( java_proto_library( name = "reviewdb_java_proto", - visibility = ["//javatests/com/google/gerrit/proto:__pkg__"], + visibility = [ + "//javatests/com/google/gerrit/proto:__pkg__", + "//tools/eclipse:__pkg__", + ], deps = [":reviewdb_proto"], ) diff --git a/tools/bzl/classpath.bzl b/tools/bzl/classpath.bzl index afdd907e6b..b60e4e4c5e 100644 --- a/tools/bzl/classpath.bzl +++ b/tools/bzl/classpath.bzl @@ -3,7 +3,8 @@ def _classpath_collector(ctx): for d in ctx.attr.deps: if hasattr(d, "java"): all += d.java.transitive_runtime_deps - all += d.java.compilation_info.runtime_classpath + if hasattr(d.java.compilation_info, "runtime_classpath"): + all += d.java.compilation_info.runtime_classpath elif hasattr(d, "files"): all += d.files diff --git a/tools/eclipse/BUILD b/tools/eclipse/BUILD index 539423b5f0..d022c40b5a 100644 --- a/tools/eclipse/BUILD +++ b/tools/eclipse/BUILD @@ -11,6 +11,7 @@ TEST_DEPS = [ "//gerrit-gwtui:ui_tests", "//javatests/com/google/gerrit/elasticsearch:elasticsearch_test_utils", "//javatests/com/google/gerrit/server:server_tests", + "//proto:reviewdb_java_proto", ] DEPS = [