unum-cloud / usearch

Fast Open-Source Search & Clustering engine × for Vectors & 🔜 Strings × in C++, C, Python, JavaScript, Rust, Java, Objective-C, Swift, C#, GoLang, and Wolfram 🔍
https://unum-cloud.github.io/usearch/
Apache License 2.0
2.27k stars 143 forks source link

Fix: Java JAR contains native library twice #430

Open MarkReedZ opened 5 months ago

MarkReedZ commented 5 months ago

This PR fixes https://github.com/unum-cloud/usearch/issues/314 by excluding the shared/ directory.

Tested with

javac -cp /usr/share/java/junit4.jar:../../build/libs/usearch-2.13.0.jar IndexTest.java
java -cp .:/usr/share/java/junit4.jar org.junit.runner.JUnitCore IndexTest
MarkReedZ commented 5 months ago

Note that a cleaner fix for this issue would probably be to not copy the dlls and load them from usearch/shared/

In the build.gradle we copy usearch/shared/* to ../ then in the code we load from /usearch. Instead we can remove the copying and load from /usearch/shared/

          NativeUtils.loadLibraryFromJar("/usearch/libusearch.dylib");
        } else {
          NativeUtils.loadLibraryFromJar("/usearch/libusearch.so");
ashvardanian commented 5 months ago

The latter sounds like a good plan. I can wait for that patch, if you want to follow up on this branch 🤗

MarkReedZ commented 5 months ago

Proper fix and verified the jar as in the OP.