@@ -4,9 +4,11 @@ load("@rules_testing//lib:analysis_test.bzl", "analysis_test", "test_suite")
44load ("@rules_testing//lib:util.bzl" , "util" )
55load ("//java:java_library.bzl" , "java_library" )
66load ("//java/common:java_common.bzl" , "java_common" )
7+ load ("//java/common:java_info.bzl" , "JavaInfo" )
78load ("//java/common:java_plugin_info.bzl" , "JavaPluginInfo" )
89load ("//java/test/testutil:java_info_subject.bzl" , "java_info_subject" )
910load ("//java/test/testutil:rules/custom_library.bzl" , "custom_library" )
11+ load ("//java/test/testutil:rules/custom_library_extended_compile_jdeps.bzl" , "CompileJdepsInfo" , "custom_library_extended_jdeps" )
1012load ("//java/test/testutil:rules/custom_library_with_exports.bzl" , "custom_library_with_exports" )
1113load ("//java/test/testutil:rules/custom_library_with_sourcepaths.bzl" , "custom_library_with_sourcepaths" )
1214
@@ -74,6 +76,32 @@ def _test_java_plugin_info_impl(env, _target):
7476 "java_common.JavaPluginInfo == JavaPluginInfo" ,
7577 ).equals (True )
7678
79+ # Tests that extended 'compile time jdeps' are consistently updated.
80+ def _test_compile_extend_compile_time_jdeps (name ):
81+ util .helper_target (
82+ custom_library_extended_jdeps ,
83+ name = name + "/foo" ,
84+ srcs = ["Foo.java" ],
85+ extra_jdeps = "Foo.jdeps" ,
86+ )
87+
88+ analysis_test (
89+ name = name ,
90+ impl = _test_compile_extend_compile_time_jdeps_impl ,
91+ target = name + "/foo" ,
92+ attr_values = {"tags" : ["min_bazel_7" ]},
93+ )
94+
95+ def _test_compile_extend_compile_time_jdeps_impl (env , target ):
96+ before = target [CompileJdepsInfo ].before .to_list ()
97+ assert_that_before = env .expect .that_collection (before )
98+ assert_that_after = env .expect .that_collection (target [CompileJdepsInfo ].after .to_list ())
99+
100+ assert_that_before .has_size (1 )
101+ assert_that_after .has_size (2 )
102+ assert_that_after .contains_at_least (before )
103+ assert_that_after .contains_exactly (target [JavaInfo ]._compile_time_java_dependencies )
104+
77105def java_common_tests (name ):
78106 test_suite (
79107 name = name ,
@@ -82,5 +110,6 @@ def java_common_tests(name):
82110 _test_compile_sourcepath ,
83111 _test_compile_exports_no_sources ,
84112 _test_java_plugin_info ,
113+ _test_compile_extend_compile_time_jdeps ,
85114 ],
86115 )
0 commit comments