Skip to content

Inconsistent behavior for generated resource files #296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
azymnis opened this issue Oct 5, 2017 · 0 comments
Closed

Inconsistent behavior for generated resource files #296

azymnis opened this issue Oct 5, 2017 · 0 comments

Comments

@azymnis
Copy link
Contributor

azymnis commented Oct 5, 2017

Problem

Scala rules have issues with generated files that are part of resources. The problem is that we are using the file.path attribute to map the destination path for these files, instead of file.short_path.

How to reproduce

Suppose that we add the following rule to test/src/main/resources/scala/test/BUILD:

genrule(
    name = "generated-hello",
    outs = ["generated-hello.txt"],
    cmd = "echo 'hello' > $@",
    visibility = ["//visibility:public"],
)

and then we modify test/BUILD to be have this:

scala_library(
    name = "ResourcesStripScalaLib",
    srcs = ["src/main/scala/scala/test/ResourcesStripScalaLib.scala"],
    resources = [
        "//test/data:more.txt",
        "//test/data:foo.txt",
        "//test/src/main/resources/scala/test:more-hellos",
        "//test/src/main/resources/scala/test:more-byes",
        "//test/src/main/resources/scala/test:generated-hello",
        ],
    resource_strip_prefix = "test/",
)

Then running this bazel build test:ResourcesStripScalaLib will generate the following error:

java.lang.RuntimeException: Resource File bazel-out/local-fastbuild/genfiles/test/src/main/resources/scala/test/generated-hello.txt is not under the specified strip prefix test/
	at io.bazel.rulesscala.scalac.ScalacProcessor.getResourcePath(ScalacProcessor.java:313)
	at io.bazel.rulesscala.scalac.ScalacProcessor.copyResources(ScalacProcessor.java:295)
	at io.bazel.rulesscala.scalac.ScalacProcessor.processRequest(ScalacProcessor.java:74)
	at io.bazel.rulesscala.worker.GenericWorker.runPersistentWorker(GenericWorker.java:52)
	at io.bazel.rulesscala.worker.GenericWorker.run(GenericWorker.java:121)
	at io.bazel.rulesscala.scalac.ScalaCInvoker.main(ScalaCInvoker.java:41)
Target //test:ResourcesStripScalaLib failed to build

@johnynek @ittaiz I've got a PR baking that can fix this, will send shortly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant