Bazel: Move java/com/google/gerrit/index:query_parser to antlr3 package

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] https://github.com/bazelbuild/bazel/issues/6010
Change-Id: Iff32b6133ff7bf3f045a20fcb635d690d76e3b89
This commit is contained in:
David Ostrovsky 2018-08-31 06:19:26 +02:00
parent 00d6bca8d0
commit f51cf2323b
4 changed files with 19 additions and 18 deletions

View File

@ -15,3 +15,17 @@ genrule2(
], ],
visibility = ["//visibility:public"], 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",
],
)

View File

@ -11,19 +11,6 @@ java_library(
visibility = ["//visibility:public"], 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( java_library(
name = "index", name = "index",
srcs = glob( srcs = glob(
@ -33,7 +20,7 @@ java_library(
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
":query_exception", ":query_exception",
":query_parser", "//antlr3:query_parser",
"//java/com/google/gerrit/common:annotations", "//java/com/google/gerrit/common:annotations",
"//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/metrics", "//java/com/google/gerrit/metrics",

View File

@ -6,9 +6,9 @@ junit_tests(
srcs = glob(["**/*.java"]), srcs = glob(["**/*.java"]),
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
"//antlr3:query_parser",
"//java/com/google/gerrit/index", "//java/com/google/gerrit/index",
"//java/com/google/gerrit/index:query_exception", "//java/com/google/gerrit/index:query_exception",
"//java/com/google/gerrit/index:query_parser",
"//lib:guava", "//lib:guava",
"//lib:junit", "//lib:junit",
"//lib/antlr:java-runtime", "//lib/antlr:java-runtime",

View File

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