diff --git a/src/java/io/bazel/rulesscala/scalac/ScalacProcessor.java b/src/java/io/bazel/rulesscala/scalac/ScalacProcessor.java index 9e43ce639..5a1446db3 100644 --- a/src/java/io/bazel/rulesscala/scalac/ScalacProcessor.java +++ b/src/java/io/bazel/rulesscala/scalac/ScalacProcessor.java @@ -291,11 +291,11 @@ private static void copyResources( dstr = resource.destination; } - if (dstr.charAt(0) == '/') { + if (dstr.charAt(0) == '/' || dstr.charAt(0) == '\\') { // we don't want to copy to an absolute destination dstr = dstr.substring(1); } - if (dstr.startsWith("../")) { + if (dstr.startsWith("../") || dstr.startsWith("..\\")) { // paths to external repositories, for some reason, start with a leading ../ // we don't want to copy the resource out of our temporary directory, so // instead we replace ../ with external/ diff --git a/test/resource_strip_prefix/BUILD b/test/resource_strip_prefix/BUILD new file mode 100644 index 000000000..f3a8b9c9a --- /dev/null +++ b/test/resource_strip_prefix/BUILD @@ -0,0 +1,10 @@ +load("//scala:scala.bzl", "scala_library") + +scala_library( + name = "test-lib", + srcs = glob( + ["src/test/scala/**/*.scala"], + ), + resource_strip_prefix = "test/resource_strip_prefix/src/test/resources", + resources = ["src/test/resources/resource.txt"], +) diff --git a/test/resource_strip_prefix/src/test/resources/resource.txt b/test/resource_strip_prefix/src/test/resources/resource.txt new file mode 100644 index 000000000..e69de29bb diff --git a/test/resource_strip_prefix/src/test/scala/RootResources.scala b/test/resource_strip_prefix/src/test/scala/RootResources.scala new file mode 100644 index 000000000..2def8557d --- /dev/null +++ b/test/resource_strip_prefix/src/test/scala/RootResources.scala @@ -0,0 +1,3 @@ +object RootResources { + +}