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
1.92k stars 109 forks source link

Fix: Java JAR contains native library twice #430

Open MarkReedZ opened 1 month ago

MarkReedZ commented 1 month 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 1 month 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 1 month 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 1 month ago

Proper fix and verified the jar as in the OP.