diff --git a/WORKSPACE b/WORKSPACE index 8d307e6ee..708662bce 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -51,6 +51,11 @@ load("//scala:scala_cross_version.bzl", "default_scala_major_version", "scala_mv MAVEN_SERVER_URLS = default_maven_server_urls() +# needed for the cross repo proto test +load("//test/proto_cross_repo_boundary:repo.bzl", "proto_cross_repo_boundary_repository") + +proto_cross_repo_boundary_repository() + # test adding a scala jar: jvm_maven_import_external( name = "com_twitter__scalding_date", diff --git a/scala/private/resources.bzl b/scala/private/resources.bzl index ff59e0026..f0e47bcc7 100644 --- a/scala/private/resources.bzl +++ b/scala/private/resources.bzl @@ -21,7 +21,8 @@ def _target_path_by_strip_prefix(resource, resource_strip_prefix): # Start from absolute resource path and then strip roots so we get to correct short path # resource.short_path sometimes give weird results ie '../' prefix path = resource.path - path = _strip_prefix(path, resource.owner.workspace_root + "/") + if resource_strip_prefix != resource.owner.workspace_root: + path = _strip_prefix(path, resource.owner.workspace_root + "/") path = _strip_prefix(path, resource.root.path + "/") # proto_library translates strip_import_prefix to proto_source_root which includes root so we have to strip it diff --git a/test/proto_cross_repo_boundary/BUILD b/test/proto_cross_repo_boundary/BUILD new file mode 100644 index 000000000..42fb573a6 --- /dev/null +++ b/test/proto_cross_repo_boundary/BUILD @@ -0,0 +1,7 @@ +load("@io_bazel_rules_scala//scala_proto:scala_proto.bzl", "scalapb_proto_library") + +scalapb_proto_library( + name = "sample_scala_proto", + visibility = ["//visibility:public"], + deps = ["@proto_cross_repo_boundary//:sample_proto"], +) diff --git a/test/proto_cross_repo_boundary/repo.bzl b/test/proto_cross_repo_boundary/repo.bzl new file mode 100644 index 000000000..0f19c06d2 --- /dev/null +++ b/test/proto_cross_repo_boundary/repo.bzl @@ -0,0 +1,6 @@ +def proto_cross_repo_boundary_repository(): + native.new_local_repository( + name = "proto_cross_repo_boundary", + path = "test/proto_cross_repo_boundary/repo", + build_file = "test/proto_cross_repo_boundary/repo/BUILD.repo", + ) diff --git a/test/proto_cross_repo_boundary/repo/BUILD.repo b/test/proto_cross_repo_boundary/repo/BUILD.repo new file mode 100644 index 000000000..26c5d732b --- /dev/null +++ b/test/proto_cross_repo_boundary/repo/BUILD.repo @@ -0,0 +1,5 @@ +proto_library( + name = "sample_proto", + srcs = ["sample.proto"], + visibility = ["//visibility:public"], +) \ No newline at end of file diff --git a/test/proto_cross_repo_boundary/repo/sample.proto b/test/proto_cross_repo_boundary/repo/sample.proto new file mode 100644 index 000000000..6fae4b202 --- /dev/null +++ b/test/proto_cross_repo_boundary/repo/sample.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package sample; + +option java_package = "sample"; + +message Sample { + repeated string foobar = 1; +} \ No newline at end of file