rules_scala
rules_scala copied to clipboard
Add unit test for precompiled native libraries
With precompiled libraries java_* rules put the library on java.library.path. scala_* rules currently do not.
Can one of the admins verify this patch?
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
:memo: Please visit https://cla.developers.google.com/ to sign.
Once you've signed, please reply here (e.g. I signed it!
) and we'll verify. Thanks.
- If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
- If you signed the CLA as a corporation, please let us know the company's name.
I signed it!
CLAs look good, thanks!
Any update on this?
Probably pretty easy to solve by adding a data dependency, but I don’t have this problem so I haven’t looked at solving it.
I have the same issue, and puting the cc_library
target as data
do not solve it.
I don't know if it changes anything, but in my case the so
is embedded in third party jar. When using it in a scala_binary
it works fine, but from within a scala_test
it does not appear in java.library.path
.
Well to be more precise, when I print java.library.path
, the jar that's supposed to contain the so
does appear in java.class.path
, however I still have an java.lang.UnsatisfiedLinkError
with a message that states that the library is not in the java.library.path
.
I created a repository to expose a minimal version of the problem : https://github.com/lgirault/jni_scala_test
I'm still fiddling with this test and what's strange is that when invoking "bazel test", the test fails but when executing the subcommand obtained by using the "-s" flags, the test works !
@lgirault I've pushed small example of JNI in Scala and Java, see if it helps: https://github.com/liucijus/bazel-jni-demo
Great ! now it works ! This is a bit frustrating that I need to add a gen_rule to extract the so
from the jar
but it seems unavoidable. I've updated my repo so that it shows the working example.
Thank you very much !
@lgirault any chance you can send a docs PR for this issue?
I can, but I'm not sure the working thing I wrote thanks to @liucijus example is the best practice. I have a genrule that extract the so library packaged by my third party dependency. Furthermore using bazel-deps my "public" target is "//3rdparty/jvm/com/eclipsesource/j2v8:j2v8_linux_x86_64" while the gen rule needs to point to the internal target "//external:jar/com/eclipsesource/j2v8/j2v8_linux_x86_64" to work. Or you just want the doc for the "simpler" use case where you have a cc_target as in @liucijus exemple ?
I think the simple case would help others yeah. Thanks!
On Fri, 15 Jan 2021 at 11:03 Loïc Girault [email protected] wrote:
I can, but I'm not sure the working thing I wrote thanks to @liucijus https://github.com/liucijus example is the best practice. I have a genrule that extract the so library packaged by my third party dependency https://github.com/lgirault/jni_scala_test/blob/main/src/scala/com/mediarithmics/lib/v8/BUILD.bazel#L3. Furthermore using bazel-deps my "public" target is "//3rdparty/jvm/com/eclipsesource/j2v8:j2v8_linux_x86_64" while the gen rule needs to point to the internal target "//external:jar/com/eclipsesource/j2v8/j2v8_linux_x86_64" to work. Or you just want the doc for the "simpler" use case where you have a cc_target as in @liucijus https://github.com/liucijus exemple ?
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/bazelbuild/rules_scala/pull/140#issuecomment-760765996, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKQQF2DJWC2KYW2O7MTJD3S2AAFDANCNFSM4C7XBEGA .
--
Ittai Zeidman
40 Hanamal street, Tel Aviv, Israel
here it is https://github.com/bazelbuild/rules_scala/pull/1182 @liucijus example speaks for itself, hence the documentation is quite short and references the example (submitted along the doc). I completed it with a scala_test target.
closing as stale, feel free to reopen