Skip to content

Commit

Permalink
Rewrite visibility handling for all java_tools
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 185959149
  • Loading branch information
ulfjack authored and Copybara-Service committed Feb 16, 2018
1 parent b653624 commit b78a5c1
Show file tree
Hide file tree
Showing 30 changed files with 125 additions and 48 deletions.
20 changes: 19 additions & 1 deletion src/java_tools/buildjar/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Description:
# JavaBuilder and java tools used by Bazel
package(default_visibility = ["//src:__subpackages__"])
package(default_visibility = [":buildjar_package_group"])

filegroup(
name = "srcs",
Expand All @@ -13,42 +13,60 @@ filegroup(
"//src/java_tools/buildjar/javatests/com/google/devtools/build/java/bazel:srcs",
"//src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine:srcs",
],
visibility = ["//:__subpackages__"],
)

package_group(
name = "buildjar_package_group",
packages = [
"//src/java_tools/buildjar/...",
"//src/tools/android/...",
],
)

java_binary(
name = "JavaBuilder",
main_class = "com.google.devtools.build.buildjar.BazelJavaBuilder",
visibility = ["//visibility:public"],
runtime_deps = ["//src/java_tools/buildjar/java/com/google/devtools/build/buildjar"],
)

java_binary(
name = "VanillaJavaBuilder",
main_class = "com.google.devtools.build.buildjar.VanillaJavaBuilder",
visibility = ["//visibility:public"],
runtime_deps = ["//src/java_tools/buildjar/java/com/google/devtools/build/buildjar:vanilla_java_builder"],
)

filegroup(
name = "JavaBuilderDeploy",
srcs = [":JavaBuilder_deploy.jar"],
tags = ["manual"],
visibility = [
":buildjar_package_group",
"//src:__pkg__",
],
)

filegroup(
name = "bootstrap_deploy.jar",
srcs = ["//src/java_tools/buildjar/java/com/google/devtools/build/buildjar:bootstrap_deploy.jar"],
tags = ["manual"],
visibility = ["//visibility:public"],
)

filegroup(
name = "bootstrap_VanillaJavaBuilder_deploy.jar",
srcs = ["//src/java_tools/buildjar/java/com/google/devtools/build/buildjar:bootstrap_VanillaJavaBuilder_deploy.jar"],
tags = ["manual"],
visibility = ["//visibility:public"],
)

filegroup(
name = "bootstrap_genclass_deploy.jar",
srcs = ["//src/java_tools/buildjar/java/com/google/devtools/build/buildjar/genclass:bootstrap_genclass_deploy.jar"],
tags = ["manual"],
visibility = ["//visibility:public"],
)

java_library(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Description:
# The Java library builders, which are used by Bazel to compile Java
# source code.
package(default_visibility = ["//src:__subpackages__"])
package(default_visibility = ["//src/java_tools/buildjar:buildjar_package_group"])

filegroup(
name = "srcs",
Expand Down Expand Up @@ -48,6 +48,10 @@ java_library(
alias(
name = "jarhelper",
actual = "//src/java_tools/buildjar/java/com/google/devtools/build/buildjar/jarhelper",
visibility = [
"//src/java_tools/buildjar:buildjar_package_group",
"//src/tools/android:__subpackages__",
],
)

# Bazel's BuildJar
Expand All @@ -64,6 +68,7 @@ java_library(
"VanillaJavaBuilder.java",
],
),
visibility = ["//src/java_tools/buildjar:buildjar_package_group"],
deps = [
":JarOwner",
":invalid_command_line_exception",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package(default_visibility = ["//src:__subpackages__"])
package(default_visibility = ["//src/java_tools/buildjar:buildjar_package_group"])

filegroup(
name = "srcs",
Expand All @@ -8,6 +8,11 @@ filegroup(
java_binary(
name = "GenClass",
main_class = "com.google.devtools.build.buildjar.genclass.GenClass",
visibility = [
"//src:__pkg__",
"//src/java_tools/buildjar:buildjar_package_group",
"//src/test/shell/bazel:__pkg__",
],
runtime_deps = [":genclass_lib"],
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package(default_visibility = ["//src:__subpackages__"])
package(default_visibility = ["//src/java_tools/buildjar:buildjar_package_group"])

filegroup(
name = "srcs",
srcs = glob(["*.java"]) + ["BUILD"],
visibility = [
"//src:__pkg__",
"//src/java_tools/buildjar:buildjar_package_group",
],
)

java_library(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Description:
# Plugins for the Java library builders, which are used by Bazel to
# compile Java source code.
package(default_visibility = ["//src:__subpackages__"])
package(default_visibility = ["//src/java_tools/buildjar:buildjar_package_group"])

java_library(
name = "plugins",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This is not the source code for javac itself.

package(
default_visibility = ["//src:__subpackages__"],
default_visibility = ["//src/java_tools/buildjar:buildjar_package_group"],
)

load(":build_defs.bzl", "default_javacopts")
Expand All @@ -26,6 +26,7 @@ java_library(
":javac-bootclasspath-locations",
],
data = ["@bazel_tools//tools/jdk:bootclasspath"],
visibility = ["//visibility:public"],
deps = ["//third_party:guava"],
)

Expand All @@ -46,6 +47,7 @@ java_library(
":java-langtools-location",
],
data = ["//third_party/java/jdk/langtools:javac_jar"],
visibility = ["//visibility:public"],
)

# Exports javacopts from the current java toolchain
Expand All @@ -62,6 +64,7 @@ java_library(
"JavaBuilderConfig.java",
"JavaBuilderJavacOpts.java",
],
visibility = ["//visibility:public"],
deps = [
"//src/java_tools/buildjar/java/com/google/devtools/build/buildjar:javac_options",
"//third_party:guava",
Expand All @@ -74,6 +77,7 @@ java_library(
name = "BazelJavaCompiler",
srcs = ["BazelJavaCompiler.java"],
data = ["//third_party/java/jdk/langtools:javac_jar"],
visibility = ["//visibility:public"],
deps = [
":JavaBuilderConfig",
":JavaLangtools",
Expand All @@ -87,6 +91,7 @@ java_library(
java_library(
name = "BazelJavac",
srcs = ["BazelJavac.java"],
visibility = ["//visibility:public"],
deps = [":BazelJavaCompiler"],
)

Expand All @@ -95,6 +100,7 @@ java_binary(
# Use same stack size as javac and JavaBuilder.
jvm_flags = ["-Xss4m"],
main_class = "com.google.devtools.build.java.bazel.BazelJavac",
visibility = ["//visibility:public"],
runtime_deps = [":BazelJavac"],
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package(default_visibility = ["//src:__subpackages__"])
package(default_visibility = ["//src/java_tools/buildjar:buildjar_package_group"])

java_binary(
name = "turbine",
main_class = "com.google.devtools.build.java.turbine.Turbine",
visibility = [
"//:__subpackages__",
"//src/java_tools/buildjar:buildjar_package_group",
],
runtime_deps = [":turbine_main"],
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package(default_visibility = ["//src:__subpackages__"])
package(default_visibility = ["//src/java_tools/buildjar:buildjar_package_group"])

java_library(
name = "javac_turbine",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package(default_visibility = ["//src:__subpackages__"])
package(default_visibility = ["//src/java_tools/buildjar:buildjar_package_group"])

filegroup(
name = "srcs",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Description:
# Tests for tools for working with Java source code
package(default_visibility = ["//src:__subpackages__"])
package(default_visibility = ["//src/java_tools/buildjar:buildjar_package_group"])

java_test(
name = "BazelJavaCompilerTest",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package(default_visibility = ["//src:__subpackages__"])
package(default_visibility = ["//src/java_tools/buildjar:buildjar_package_group"])

filegroup(
name = "srcs",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package(default_visibility = ["//src:__subpackages__"])
package(default_visibility = ["//src/java_tools/buildjar:buildjar_package_group"])

java_library(
name = "AbstractJavacTurbineCompilationTest",
Expand Down
8 changes: 7 additions & 1 deletion src/java_tools/junitrunner/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Description:
# Run JUnit tests in a controlled environment.
package(default_visibility = ["//src:__subpackages__"])
package(default_visibility = ["//visibility:private"])

filegroup(
name = "srcs",
Expand All @@ -12,4 +12,10 @@ filegroup(
"//src/java_tools/junitrunner/javatests/com/google/testing/junit/junit4/runner:srcs",
"//src/java_tools/junitrunner/javatests/com/google/testing/junit/runner:srcs",
],
visibility = ["//:__subpackages__"],
)

package_group(
name = "junitrunner_package_group",
packages = ["//src/java_tools/junitrunner/..."],
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package(
default_testonly = 1,
default_visibility = ["//src:__subpackages__"],
default_visibility = ["//visibility:public"],
)

# Libraries
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package(default_visibility = ["//src:__subpackages__"])
package(default_visibility = [
"//src/java_tools/junitrunner:junitrunner_package_group",
])

filegroup(
name = "common_runner_java_files",
Expand Down Expand Up @@ -50,12 +52,20 @@ java_library(
java_binary(
name = "Runner",
main_class = "com.google.testing.junit.runner.BazelTestRunner",
visibility = [
"//src:__subpackages__",
"//src/java_tools/junitrunner:junitrunner_package_group",
],
runtime_deps = [":test_runner"],
)

java_binary(
name = "ExperimentalRunner",
main_class = "com.google.testing.junit.runner.ExperimentalTestRunner",
visibility = [
"//src:__pkg__",
"//src/java_tools/junitrunner:junitrunner_package_group",
],
runtime_deps = [":experimental_test_runner"],
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package(default_visibility = ["//src:__subpackages__"])
package(default_visibility = [
"//src/java_tools/junitrunner:junitrunner_package_group",
])

# Internal code for the JUnit runner that does not depend on JUnit 4.
# Code used by the JUnit runner that does depend on JUnit 4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package(default_visibility = ["//src:__subpackages__"])
package(default_visibility = [
"//src/java_tools/junitrunner:junitrunner_package_group",
])

# JUnit4 test runner core code.
java_library(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package(default_visibility = ["//src:__subpackages__"])
package(default_visibility = [
"//src/java_tools/junitrunner:junitrunner_package_group",
])

java_library(
name = "model",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package(default_visibility = ["//src:__subpackages__"])
package(default_visibility = [
"//src/java_tools/junitrunner:junitrunner_package_group",
])

# TODO(bazel-team): This should be testonly = 1.
java_library(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package(default_visibility = ["//src:__subpackages__"])
package(default_visibility = [
"//src/java_tools/junitrunner:junitrunner_package_group",
])

# TODO(bazel-team): This should be testonly = 1.
java_library(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package(default_visibility = ["//src:__subpackages__"])
package(default_visibility = [
"//src/java_tools/junitrunner:junitrunner_package_group",
])

java_library(
name = "testing",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package(default_visibility = ["//src:__subpackages__"])
package(default_visibility = [
"//src/java_tools/junitrunner:junitrunner_package_group",
])

java_library(
name = "util",
srcs = glob(["*.java"]),
visibility = ["//visibility:public"],
deps = [
"//third_party:jsr305",
"//third_party:junit4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package(default_visibility = ["//src:__subpackages__"])
package(default_visibility = [
"//src/java_tools/junitrunner:junitrunner_package_group",
])

filegroup(
name = "srcs",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package(default_visibility = ["//src:__subpackages__"])
package(default_visibility = [
"//src/java_tools/junitrunner:junitrunner_package_group",
])

# Libraries
# =========================================================
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package(default_visibility = ["//src:__subpackages__"])
package(default_visibility = [
"//src/java_tools/junitrunner:junitrunner_package_group",
])

java_library(
name = "testbed",
Expand Down
Loading

0 comments on commit b78a5c1

Please sign in to comment.