add srcs filegroups for import_deps_checker
Change-Id: I1fa7867ffb08af95c1eef5ae3e32cff34292328b
PiperOrigin-RevId: 185189976
diff --git a/src/BUILD b/src/BUILD
index 755e88c..5ae5387 100644
--- a/src/BUILD
+++ b/src/BUILD
@@ -322,6 +322,7 @@
srcs = glob(["**"]) + [
"//src/conditions:srcs",
"//src/java_tools/buildjar:srcs",
+ "//src/java_tools/import_deps_checker:srcs",
"//src/java_tools/junitrunner:srcs",
"//src/java_tools/singlejar:srcs",
"//src/main/cpp:srcs",
diff --git a/src/java_tools/import_deps_checker/BUILD b/src/java_tools/import_deps_checker/BUILD
new file mode 100644
index 0000000..d0b39b8
--- /dev/null
+++ b/src/java_tools/import_deps_checker/BUILD
@@ -0,0 +1,10 @@
+package(default_visibility = ["//src:__subpackages__"])
+
+filegroup(
+ name = "srcs",
+ srcs = [
+ "BUILD",
+ "//src/java_tools/import_deps_checker/java/com/google/devtools/build/importdeps:srcs",
+ "//src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps:srcs",
+ ],
+)
diff --git a/src/java_tools/import_deps_checker/java/com/google/devtools/build/importdeps/BUILD b/src/java_tools/import_deps_checker/java/com/google/devtools/build/importdeps/BUILD
index a9d4cd3..a9c3ab5 100644
--- a/src/java_tools/import_deps_checker/java/com/google/devtools/build/importdeps/BUILD
+++ b/src/java_tools/import_deps_checker/java/com/google/devtools/build/importdeps/BUILD
@@ -5,6 +5,11 @@
default_visibility = ["//src:__subpackages__"],
)
+filegroup(
+ name = "srcs",
+ srcs = glob(["**"]),
+)
+
java_library(
name = "import_deps_checker",
srcs = glob(
@@ -13,11 +18,12 @@
),
deps = [
"//third_party:asm",
+ "//third_party:asm-commons",
+ "//third_party:asm-tree",
"//third_party:auto_value",
"//third_party:guava",
"//third_party:jsr305",
- "//third_party/java/asm:asm-commons",
- "//third_party/java/asm:asm-tree",
+ "//third_party:junit4",
],
)
diff --git a/src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/BUILD b/src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/BUILD
index de8ffba..16af1d6 100644
--- a/src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/BUILD
+++ b/src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/BUILD
@@ -5,6 +5,12 @@
default_visibility = ["//src:__subpackages__"],
)
+filegroup(
+ name = "srcs",
+ testonly = False,
+ srcs = glob(["**"]) + ["//src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata:srcs"],
+)
+
java_test(
name = "ClassInfoTest",
srcs = ["ClassInfoTest.java"],
@@ -32,7 +38,7 @@
srcs = ["LazyClassEntryStateTest.java"],
deps = [
"//src/java_tools/import_deps_checker/java/com/google/devtools/build/importdeps:import_deps_checker",
- "//src/test/java/com/google/devtools/build/lib/testutil:JunitUtils",
+ "//src/test/java/com/google/devtools/build/lib:testutil",
"//third_party:guava",
"//third_party:junit4",
"//third_party:truth",
@@ -52,10 +58,10 @@
"//src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata:testdata_lib_LibraryException",
"//src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata:testdata_lib_LibraryInterface",
"//src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata:testdata_lib_Library_no_members",
- "//third_party/java/jdk:jdk8_rt_jar",
+ "@local_jdk//:jre/lib/rt.jar",
],
jvm_flags = [
- "-Dclasscache.test.bootclasspath=$(location //third_party/java/jdk:jdk8_rt_jar)",
+ "-Dclasscache.test.bootclasspath=$(location @local_jdk//:jre/lib/rt.jar)",
"-Dclasscache.test.Client=$(location //src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata:testdata_client)",
"-Dclasscache.test.Library=$(location //src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata:testdata_lib_Library)",
"-Dclasscache.test.Library_no_members=$(location //src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata:testdata_lib_Library_no_members)",
@@ -66,6 +72,7 @@
test_class = "com.google.devtools.build.importdeps.ClassCacheTest",
deps = [
"//src/java_tools/import_deps_checker/java/com/google/devtools/build/importdeps:import_deps_checker",
+ "//src/test/java/com/google/devtools/build/lib:testutil",
"//third_party:guava",
"//third_party:junit4",
"//third_party:truth",
@@ -85,10 +92,10 @@
"//src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata:testdata_lib_LibraryException",
"//src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata:testdata_lib_LibraryInterface",
"//src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata:testdata_lib_Library_no_members",
- "//third_party/java/jdk:jdk8_rt_jar",
+ "@local_jdk//:jre/lib/rt.jar",
],
jvm_flags = [
- "-Dclasscache.test.bootclasspath=$(location //third_party/java/jdk:jdk8_rt_jar)",
+ "-Dclasscache.test.bootclasspath=$(location @local_jdk//:jre/lib/rt.jar)",
"-Dclasscache.test.Client=$(location //src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata:testdata_client)",
"-Dclasscache.test.Library=$(location //src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata:testdata_lib_Library)",
"-Dclasscache.test.Library_no_members=$(location //src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata:testdata_lib_Library_no_members)",
@@ -103,7 +110,7 @@
"//third_party:guava",
"//third_party:junit4",
"//third_party:truth",
- "//third_party/java/jdk:jdk8_rt_jar",
+ "@local_jdk//:jre/lib/rt.jar",
],
)
@@ -113,49 +120,70 @@
name = "bootclasspath_missing_golden_test",
golden_file = "golden_bootclasspath_missing.txt",
has_bootclasspath = False,
+ import_deps_checker = "//src/java_tools/import_deps_checker/java/com/google/devtools/build/importdeps:ImportDepsChecker",
missing_jar = None,
+ rt_jar = "@local_jdk//:jre/lib/rt.jar",
+ testdata_pkg = "//src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata",
)
create_golden_test(
name = "library_exception_missing_golden_test",
golden_file = "golden_library_exception_missing.txt",
has_bootclasspath = True,
+ import_deps_checker = "//src/java_tools/import_deps_checker/java/com/google/devtools/build/importdeps:ImportDepsChecker",
missing_jar = "testdata_lib_LibraryException",
+ rt_jar = "@local_jdk//:jre/lib/rt.jar",
+ testdata_pkg = "//src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata",
)
create_golden_test(
name = "library_annotation_missing_golden_test",
golden_file = "golden_library_annotation_missing.txt",
has_bootclasspath = True,
+ import_deps_checker = "//src/java_tools/import_deps_checker/java/com/google/devtools/build/importdeps:ImportDepsChecker",
missing_jar = "testdata_lib_LibraryAnnotations",
+ rt_jar = "@local_jdk//:jre/lib/rt.jar",
+ testdata_pkg = "//src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata",
)
create_golden_test(
name = "library_missing_golden_test",
golden_file = "golden_library_missing.txt",
has_bootclasspath = True,
+ import_deps_checker = "//src/java_tools/import_deps_checker/java/com/google/devtools/build/importdeps:ImportDepsChecker",
missing_jar = "testdata_lib_Library",
+ rt_jar = "@local_jdk//:jre/lib/rt.jar",
+ testdata_pkg = "//src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata",
)
create_golden_test(
name = "library_interface_missing_golden_test",
golden_file = "golden_library_interface_missing.txt",
has_bootclasspath = True,
+ import_deps_checker = "//src/java_tools/import_deps_checker/java/com/google/devtools/build/importdeps:ImportDepsChecker",
missing_jar = "testdata_lib_LibraryInterface",
+ rt_jar = "@local_jdk//:jre/lib/rt.jar",
+ testdata_pkg = "//src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata",
)
create_golden_test(
name = "library_members_missing_golden_test",
golden_file = "golden_library_members_missing.txt",
has_bootclasspath = True,
+ import_deps_checker = "//src/java_tools/import_deps_checker/java/com/google/devtools/build/importdeps:ImportDepsChecker",
missing_jar = "testdata_lib_Library",
replacing_jar = "testdata_lib_Library_no_members",
+ rt_jar = "@local_jdk//:jre/lib/rt.jar",
+ testdata_pkg = "//src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata",
)
create_golden_test(
name = "complete_classpath_golden_test",
golden_file = "golden_complete_classpath.txt",
has_bootclasspath = True,
+ import_deps_checker = "//src/java_tools/import_deps_checker/java/com/google/devtools/build/importdeps:ImportDepsChecker",
missing_jar = None,
replacing_jar = None,
+ rt_jar = "@local_jdk//:jre/lib/rt.jar",
+ testdata_pkg = "//src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata",
)
diff --git a/src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/ClassCacheTest.java b/src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/ClassCacheTest.java
index 241afd9..8049621 100644
--- a/src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/ClassCacheTest.java
+++ b/src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/ClassCacheTest.java
@@ -15,7 +15,7 @@
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
-import static org.junit.Assert.assertThrows;
+import static com.google.devtools.build.lib.testutil.MoreAsserts.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.devtools.build.importdeps.AbstractClassEntryState.ExistingState;
diff --git a/src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata/BUILD b/src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata/BUILD
index ae40513..a54fed8 100644
--- a/src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata/BUILD
+++ b/src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata/BUILD
@@ -2,7 +2,15 @@
# Test data for testing dependency checking.
package(
default_testonly = 1,
- default_visibility = ["//src:__subpackages__"],
+ default_visibility = ["//src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps:__subpackages__"],
+)
+
+licenses(["notice"]) # Apache 2.0
+
+filegroup(
+ name = "srcs",
+ testonly = False,
+ srcs = glob(["**"]),
)
java_library(
diff --git a/src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/tests.bzl b/src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/tests.bzl
index 3edf246..df7069f 100644
--- a/src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/tests.bzl
+++ b/src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/tests.bzl
@@ -13,7 +13,9 @@
# limitations under the License.
'''Helpers to create golden tests, to minimize code duplication.'''
-def create_golden_test(name, golden_file, has_bootclasspath, missing_jar = None, replacing_jar = None):
+def create_golden_test(name, golden_file, has_bootclasspath, testdata_pkg,
+ import_deps_checker, rt_jar, missing_jar = None,
+ replacing_jar = None):
'''Create a golden test for the dependency checker.'''
all_dep_jars = [
"testdata_client",
@@ -22,13 +24,11 @@
"testdata_lib_LibraryException",
"testdata_lib_LibraryInterface",
]
- testdata_pkg = "//third_party/bazel/src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/testdata"
- import_deps_checker = "//third_party/bazel/src/java_tools/import_deps_checker/java/com/google/devtools/build/importdeps:ImportDepsChecker"
client_jar = testdata_pkg + ":testdata_client"
data = [
golden_file,
import_deps_checker,
- "//third_party/java/jdk:jdk8_rt_jar"
+ rt_jar,
] + [testdata_pkg + ":" + x for x in all_dep_jars]
if (replacing_jar):
data.append(testdata_pkg + ":" + replacing_jar)
@@ -39,7 +39,7 @@
]
args.append("--bootclasspath_entry")
if has_bootclasspath:
- args.append("$(location //third_party/java/jdk:jdk8_rt_jar)")
+ args.append("$(location %s)" % rt_jar)
else:
args.append("$(location %s)" % client_jar) # Fake bootclasspath.