Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deploy/scripts/run-tile-pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ geometry_mapping() {
GEOMETRY_MAPPING_CACHE_PATH="${cache_dir}/geometry_mapping.json" \
GEOMETRY_MAPPING_REPORT_PATH="${cache_dir}/geometry_mapping_report.txt" \
GEOMETRY_MAPPING_JSON_REPORT_PATH="${cache_dir}/geometry_mapping_report.json" \
java -cp "${jar}" global.tada.valhalla.traffic.sg.GeometryMappingJob \
java -cp "${jar}:/app/lib/*" global.tada.valhalla.traffic.sg.GeometryMappingJob \
|| job_exit_code=$?

case "${job_exit_code}" in
Expand Down
13 changes: 12 additions & 1 deletion docker/Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ RUN MULTIARCH=$(gcc-13 -print-multiarch) && \
RUN --mount=type=cache,target=/root/.gradle \
cd src/bindings/java && \
chmod +x gradlew && \
./gradlew clean build -x buildNative -x test && \
./gradlew clean build copyRuntimeDeps -x buildNative -x test && \
echo "✅ Gradle JAR build complete"

# ── Verify artifacts ─────────────────────────────────────────────────────────
Expand Down Expand Up @@ -262,6 +262,17 @@ RUN JAR=$(ls /tmp/jni-jars/valhalla-jni-*.jar | grep -v sources | grep -v javado
chown valhalla:valhalla /app/valhalla-jni.jar && \
rm -rf /tmp/jni-jars

# Runtime dependencies for standalone JVM invocations.
# The thin /app/valhalla-jni.jar above does not bundle transitive deps (SLF4J,
# Kotlin stdlib, coroutines, org.json), so `java -cp /app/valhalla-jni.jar
# GeometryMappingJob` in run-tile-pipeline.sh would fail with NoClassDefFoundError.
# Gradle's `copyRuntimeDeps` task produces these jars at build/libs/runtime/.
COPY --from=builder /build/src/bindings/java/build/libs/runtime/ /tmp/jni-runtime/
RUN mkdir -p /app/lib && \
cp /tmp/jni-runtime/*.jar /app/lib/ && \
chown -R valhalla:valhalla /app/lib && \
rm -rf /tmp/jni-runtime

COPY --from=builder --chown=valhalla:valhalla \
/build/config \
/app/config
Expand Down
21 changes: 21 additions & 0 deletions src/bindings/java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ dependencies {

// Logging
implementation(libs.slf4j.api)
// Runtime binding for standalone JVM invocations (see `copyRuntimeDeps` below).
// Spring Boot consumers bring their own binding so this is `runtimeOnly`, not
// `implementation` — they don't see it on their compile/runtime classpath.
runtimeOnly(libs.slf4j.simple)

// JSON parsing
implementation(libs.json)
Expand Down Expand Up @@ -220,6 +224,23 @@ tasks.jar {
isReproducibleFileOrder = true
}

// ============================================
// Runtime Dependencies for Standalone JVM Use
// ============================================
// The published `valhalla-jni-*.jar` is thin — project classes + native libs only.
// For standalone CLI invocations like `java -cp valhalla-jni.jar GeometryMappingJob`
// (see deploy/scripts/run-tile-pipeline.sh) the transitive deps (SLF4J, Kotlin
// stdlib, coroutines, org.json) must also be on the classpath. This task copies
// runtime deps to build/libs/runtime/ so the Dockerfile can ship them under
// /app/lib/. Invoked explicitly from Dockerfile.prod; not wired to `jar`/`assemble`
// so downstream maven consumers don't pay for it.
tasks.register<Copy>("copyRuntimeDeps") {
description = "Copies runtime dependencies to build/libs/runtime/ for Docker packaging."
group = "build"
from(configurations.runtimeClasspath)
into(layout.buildDirectory.dir("libs/runtime"))
}

// ============================================
// Documentation (Dokka)
// ============================================
Expand Down
1 change: 1 addition & 0 deletions src/bindings/java/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
slf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "slf4j" }
json = { module = "org.json:json", version.ref = "json" }
logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "logback" }
junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" }
Expand Down
Loading