diff --git a/java/osgi/osgi.bzl b/java/osgi/osgi.bzl index ec0b18a96a..40ee0842a5 100644 --- a/java/osgi/osgi.bzl +++ b/java/osgi/osgi.bzl @@ -164,7 +164,12 @@ def _osgi_jar_impl(ctx): fail("osgi_jar rule can only be used on a single java target.") target_java_output = ctx.attr.target[JavaInfo].java_outputs[0] - if len(target_java_output.source_jars) > 1: + # source_jars may be a list or a Depset due to: + # https://github.com/bazelbuild/bazel/issues/18966 + source_jars = target_java_output.source_jars + if hasattr(source_jars, "to_list"): + source_jars = source_jars.to_list() + if len(source_jars) > 1: fail("osgi_jar rule doesn't know how to deal with more than one source jar.") source_jar = target_java_output.source_jars[0]