Migrate the `JavaInfoStarlarkApiTest.buildHelperCreateJavaInfoWithCompileJdeps_javaRuleOutputJarsProvider` test to Starlark
The test is removed from Bazel and added in rules_java
PiperOrigin-RevId: 734651588
Change-Id: I038eba7eeca6a6d51cd6e77e457e4cf0f6ac3c64
diff --git a/java/test/common/java_info_tests.bzl b/java/test/common/java_info_tests.bzl
index 1b66f9c..9e4d1a3 100644
--- a/java/test/common/java_info_tests.bzl
+++ b/java/test/common/java_info_tests.bzl
@@ -802,6 +802,26 @@
assert_annotation_processing.class_jar().short_path_equals("{package}/generated_class.jar")
assert_annotation_processing.source_jar().short_path_equals("{package}/generated_srcs.jar")
+def _with_compile_jdeps_test(name):
+ target_name = name + "/my_starlark_rule"
+ util.helper_target(
+ custom_java_info_rule,
+ name = target_name,
+ compile_jdeps = "compile.deps",
+ output_jar = target_name + "/my_starlark_rule_lib.jar",
+ )
+
+ analysis_test(
+ name = name,
+ impl = _with_compile_jdeps_test_impl,
+ target = target_name,
+ )
+
+def _with_compile_jdeps_test_impl(env, target):
+ java_info_subject.from_target(env, target).outputs().compile_jdeps().contains_exactly([
+ "{package}/compile.deps",
+ ])
+
def java_info_tests(name):
test_suite(
name = name,
@@ -830,5 +850,6 @@
_with_jdeps_test,
_with_generated_jars_outputs_test,
_with_generated_jars_annotation_processing_test,
+ _with_compile_jdeps_test,
],
)
diff --git a/java/test/testutil/java_info_subject.bzl b/java/test/testutil/java_info_subject.bzl
index 9ff3631..a3db4ba 100644
--- a/java/test/testutil/java_info_subject.bzl
+++ b/java/test/testutil/java_info_subject.bzl
@@ -46,6 +46,7 @@
generated_class_jars = lambda: subjects.depset_file(depset([o.generated_class_jar for o in actual.jars]), self.meta.derive("generated_class_jars")),
generated_source_jars = lambda: subjects.depset_file(depset([o.generated_source_jar for o in actual.jars]), self.meta.derive("generated_source_jars")),
jdeps = lambda: subjects.depset_file(depset([o.jdeps for o in actual.jars]), self.meta.derive("jdeps")),
+ compile_jdeps = lambda: subjects.depset_file(depset([o.compile_jdeps for o in actual.jars]), self.meta.derive("compile_jdeps")),
)
return public
diff --git a/java/test/testutil/rules/custom_java_info_rule.bzl b/java/test/testutil/rules/custom_java_info_rule.bzl
index cb198ae..a74f9c3 100644
--- a/java/test/testutil/rules/custom_java_info_rule.bzl
+++ b/java/test/testutil/rules/custom_java_info_rule.bzl
@@ -49,6 +49,7 @@
native_libraries = dp_libs,
neverlink = ctx.attr.neverlink,
jdeps = ctx.file.jdeps,
+ compile_jdeps = ctx.file.compile_jdeps,
generated_class_jar = ctx.file.generated_class_jar,
generated_source_jar = ctx.file.generated_source_jar,
),
@@ -66,6 +67,7 @@
"dep_exported_plugins": attr.label_list(),
"cc_dep": attr.label_list(),
"jdeps": attr.label(allow_single_file = True),
+ "compile_jdeps": attr.label(allow_single_file = True),
"generated_class_jar": attr.label(allow_single_file = True),
"generated_source_jar": attr.label(allow_single_file = True),
"use_ijar": attr.bool(default = False),