Gradle is the recommended route, since Maven Central does not carry the native builds; this Groovy script downloads a “fat JAR” carrying builds for Linux, Windows, macOS, and Android:
repositories {
mavenCentral()
flatDir { dirs 'lib' }
}
task downloadUSearchJar {
doLast {
def usearchVersion = '3.0.0'
def usearchUrl = "https://github.com/unum-cloud/USearch/releases/download/v$usearchVersion/usearch-${usearchVersion}.jar"
def usearchFile = file("lib/usearch-${usearchVersion}.jar")
usearchFile.parentFile.mkdirs()
if (!usearchFile.exists()) {
new URL(usearchUrl).withInputStream { source -> usearchFile.withOutputStream { it << source } }
}
}
}
compileJava.dependsOn downloadUSearchJar
dependencies {
implementation name: 'usearch', version: '3.0.0', ext: 'jar'
}Gradle drives CMake for the engine, so building from source needs nothing else, and -PusearchPrebuilt points the suites at an engine CMake already built:
gradle clean build # engine, SDK, and the Java, Kotlin and Scala suites
gradle -PusearchPrebuilt=$PWD/build_release test # against a library built beforehandThe SDK looks for the shared object on the system library path first, which a locally built tree offers, and otherwise extracts the platform’s copy packaged inside the JAR to a temporary directory.
§ Source Layout & Imports
One source file mirrors one header. Types.java carries the shared vocabulary: Key, Status, Scalar, Residency, Traversal, Executor, Arena, Mood, Deferred, USearchException, RowsView, and the arena-backed Matches and Monolith. DenseIndex.java carries the dense modality: the index itself, its On and DeferredOn receivers, DenseOptions, DenseMetric, DenseMetadata, DenseIndexDescription, DenseReachability, DenseTraversalStats, the Dense*Config knobs, ValueLookup, the arena-backed DenseVectors, DenseProducts and DenseBatch, and the DenseCursor and DenseSearchStream scans. DenseVerbs.java writes the blocking verbs once for the index and its On receiver. Library.java loads the shared object and links every verb against it.
Both vocabularies are nested types, and a nested type imports directly, so every call site below spells the bare name:
import cloud.unum.usearch.DenseIndex;
import cloud.unum.usearch.DenseIndex.DenseMetric;
import cloud.unum.usearch.DenseIndex.DenseOptions;
import cloud.unum.usearch.DenseIndex.DenseSearchConfig;
import cloud.unum.usearch.Types.Arena;
import cloud.unum.usearch.Types.Deferred;
import cloud.unum.usearch.Types.Executor;
import cloud.unum.usearch.Types.Key;
import cloud.unum.usearch.Types.Matches;
import cloud.unum.usearch.Types.RowsView;
import cloud.unum.usearch.Types.Scalar;