Skip to content

Commit

Permalink
Bazel: Move java/com/google/gerrit/index:query_parser to antlr3 package
Browse files Browse the repository at this point in the history
In I75d6bc4d7a antlr3 grammar sources were moved from gerrit-antlr
package, but the java_library rule query_parser were missed to also be
moved to antlr3 package. This is very unusual in Bazel toolchain to keep
the sources in one package and build them in another. This leads to a
problem: restricting package_group in java_package_configuration doesn't
lead to the desired effect, as discussed in this issue: [1].

Moving the query_parser rule to the antlr3 package harmonize the
location of the java_library rule to the same package where the sources
are located and it also fixes the problem, that error prone warnings are
not reported any more for the antlr3 grammar source in new toolchain,
that doesn't list antlr3 in the package_group. ntlr3 grammar code is
generated code and we would rather avoid reporting any issues in that
code.

[1] bazelbuild/bazel#6010
Change-Id: Iff32b6133ff7bf3f045a20fcb635d690d76e3b89
  • Loading branch information
davido committed Aug 31, 2018
1 parent 00d6bca commit f51cf23
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
14 changes: 14 additions & 0 deletions antlr3/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,17 @@ genrule2(
],
visibility = ["//visibility:public"],
)

java_library(
name = "query_parser",
srcs = [":query"],
visibility = [
"//java/com/google/gerrit/index:__pkg__",
"//javatests/com/google/gerrit/index:__pkg__",
"//plugins:__pkg__",
],
deps = [
"//java/com/google/gerrit/index:query_exception",
"//lib/antlr:java-runtime",
],
)
15 changes: 1 addition & 14 deletions java/com/google/gerrit/index/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,6 @@ java_library(
visibility = ["//visibility:public"],
)

java_library(
name = "query_parser",
srcs = ["//antlr3:query"],
visibility = [
"//javatests/com/google/gerrit/index:__pkg__",
"//plugins:__pkg__",
],
deps = [
":query_exception",
"//lib/antlr:java-runtime",
],
)

java_library(
name = "index",
srcs = glob(
Expand All @@ -33,7 +20,7 @@ java_library(
visibility = ["//visibility:public"],
deps = [
":query_exception",
":query_parser",
"//antlr3:query_parser",
"//java/com/google/gerrit/common:annotations",
"//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/metrics",
Expand Down
2 changes: 1 addition & 1 deletion javatests/com/google/gerrit/index/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ junit_tests(
srcs = glob(["**/*.java"]),
visibility = ["//visibility:public"],
deps = [
"//antlr3:query_parser",
"//java/com/google/gerrit/index",
"//java/com/google/gerrit/index:query_exception",
"//java/com/google/gerrit/index:query_parser",
"//lib:guava",
"//lib:junit",
"//lib/antlr:java-runtime",
Expand Down
6 changes: 3 additions & 3 deletions plugins/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ PLUGIN_API = [
]

EXPORTS = [
"//antlr3:query_parser",
"//java/com/google/gerrit/common:annotations",
"//java/com/google/gerrit/common:server",
"//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/index",
"//java/com/google/gerrit/index:query_exception",
"//java/com/google/gerrit/index:query_parser",
"//java/com/google/gerrit/lifecycle",
"//java/com/google/gerrit/metrics",
"//java/com/google/gerrit/metrics/dropwizard",
Expand Down Expand Up @@ -100,13 +100,13 @@ java_binary(
main_class = "Dummy",
visibility = ["//visibility:public"],
runtime_deps = [
"//antlr3:libquery_parser-src.jar",
"//java/com/google/gerrit/common:libannotations-src.jar",
"//java/com/google/gerrit/common:libserver-src.jar",
"//java/com/google/gerrit/extensions:libapi-src.jar",
"//java/com/google/gerrit/httpd:libhttpd-src.jar",
"//java/com/google/gerrit/index:libindex-src.jar",
"//java/com/google/gerrit/index:libquery_exception-src.jar",
"//java/com/google/gerrit/index:libquery_parser-src.jar",
"//java/com/google/gerrit/pgm/init/api:libapi-src.jar",
"//java/com/google/gerrit/reviewdb:libserver-src.jar",
"//java/com/google/gerrit/server:libserver-src.jar",
Expand All @@ -121,9 +121,9 @@ load("//tools/bzl:javadoc.bzl", "java_doc")
java_doc(
name = "plugin-api-javadoc",
libs = PLUGIN_API + [
"//antlr3:query_parser",
"//java/com/google/gerrit/index",
"//java/com/google/gerrit/index:query_exception",
"//java/com/google/gerrit/index:query_parser",
"//java/com/google/gerrit/common:annotations",
"//java/com/google/gerrit/common:server",
"//java/com/google/gerrit/extensions:api",
Expand Down

0 comments on commit f51cf23

Please sign in to comment.