Skip to content
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

getClass.getResource yields wrong result using 1.9.9 with sbtPlugin := true #7514

Open
agboom opened this issue Mar 15, 2024 · 3 comments
Open

Comments

@agboom
Copy link

agboom commented Mar 15, 2024

steps

See https://github.com/agboom/sbt-resource-test for a repro project.

problem

In a nutshell: when I call getClass.getResource in sbt 1.9.8, the local resource directory URL is returned.

In 1.9.9, a Jar URL is returned: jar:file:~/.sbt/boot/scala-2.12.18/org.scala-sbt/sbt/1.9.9/jansi-2.4.1.jar!/META-INF/versions/9/.

I created a repro, with a GH workflow that reproduces the problem. The workflow run with logs can be found here: https://github.com/agboom/sbt-resource-test/actions/runs/8297335057

For completeness I added both Java 11 and 17 to the build matrix, but the Java version doesn't seem to affect or cause the bug.

expectation

I expect the behavior to be the same as 1.9.8

notes

This is my first issue here, so let me know if you need more information.

Looking at the diff between 1.9.8 and 1.9.9, the Jansi dependency seems to have been updated. Could this be part of the cause? v1.9.8...v1.9.9#diff-ad2642dc77b3679e4ad2c7d3b2f59a2dcf48c1bf5b93a558a4fa44828315a34cR96

@eed3si9n
Copy link
Member

Thanks for the bug report with repro project!

@eed3si9n
Copy link
Member

Would adding

Test / fork := true

change the result?

@agboom
Copy link
Author

agboom commented Mar 18, 2024

@eed3si9n Thanks for your reply and suggestion! Setting fork to true indeed makes it work again. Do you have an idea why this makes a difference? I found some documentation about the limitations of forking, also related to class loading[1][2][3], but not this particular problem.

1: https://www.scala-sbt.org/1.x/docs/Forking.html
2: https://www.scala-sbt.org/1.x/docs/Testing.html#Setup+and+Cleanup
3: https://www.scala-sbt.org/1.x/docs/Running-Project-Code.html

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

No branches or pull requests

2 participants