Make java_grpc_library work with proto_library rules using strip_import_prefix / import_prefix.
In addition to this welcome functionality, this change also makes it possible to fix by tolerating proto_library rules using a virtual import directory.
@@ -7,6 +7,10 @@ def _path_ignoring_repository(f):
if (len(f.owner.workspace_root) == 0):
return f.short_path
+ virtual_imports = "/_virtual_imports/"
+ if virtual_imports in f.path:
+ return f.path.split(virtual_imports)[1].split("/", 1)[1]
+ else:
# If |f| is a generated file, it will have "bazel-out/*/genfiles" prefix
# before "external/workspace", so we need to add the starting index of "external/workspace"
return f.path[f.path.find(f.owner.workspace_root) + len(f.owner.workspace_root) + 1:]
