From 686dd9f71f2562a15c668e813f100f3746e89bf6 Mon Sep 17 00:00:00 2001 From: brios <127139797+balazs-szucs@users.noreply.github.com> Date: Sun, 10 May 2026 22:33:52 +0200 Subject: [PATCH] chore(deps): bump epub4j and epub4j-native versions to 1.4.0 (#1090) Co-authored-by: James Ward --- backend/build.gradle.kts | 74 +++++++++++++++++++++++++++++++++++----- backend/gradle.lockfile | 4 +-- 2 files changed, 67 insertions(+), 11 deletions(-) diff --git a/backend/build.gradle.kts b/backend/build.gradle.kts index c1881e6ac..57bf363d6 100644 --- a/backend/build.gradle.kts +++ b/backend/build.gradle.kts @@ -68,13 +68,17 @@ fun pdfiumNativesClassifier(): String { "win" in osName -> "windows" "mac" in osName || "darwin" in osName -> "darwin" "nux" in osName || "linux" in osName -> { - val isMusl = try { - val libDir = File("/lib") - libDir.exists() && (libDir.listFiles()?.any { f -> f.name.startsWith("ld-musl-") } == true) - } catch (_: Exception) { - try { - File("/proc/self/maps").readText().contains("musl") - } catch (_: Exception) { false } + val libcOverride = (System.getenv("TARGETLIBC") + ?: project.findProperty("targetLibc")?.toString())?.lowercase() + val isMusl = when (libcOverride) { + "musl" -> true + "gnu", "glibc" -> false + else -> if (targetPlatform != null) false else runCatching { + val libDir = File("/lib") + libDir.exists() && (libDir.listFiles()?.any { f -> f.name.startsWith("ld-musl-") } == true) + }.getOrElse { + runCatching { File("/proc/self/maps").readText().contains("musl") }.getOrDefault(false) + } } if (isMusl) "linux-musl" else "linux" } @@ -90,6 +94,56 @@ fun pdfiumNativesClassifier(): String { return "natives-$osKey-$archKey" } +fun epub4jNativesClassifier(): String { + // Support cross-compilation: check for explicit target overrides first + val targetPlatform = System.getenv("TARGETPLATFORM") + ?: project.findProperty("targetPlatform")?.toString() + val targetArch = System.getenv("TARGETARCH") + ?: project.findProperty("targetArch")?.toString() + + val osName: String + val arch: String + + if (targetPlatform != null) { + // Docker TARGETPLATFORM format: linux/amd64, linux/arm64 + val parts = targetPlatform.split("/") + osName = parts.getOrElse(0) { "linux" } + arch = parts.getOrElse(1) { "amd64" } + } else { + osName = System.getProperty("os.name").lowercase() + arch = targetArch ?: System.getProperty("os.arch").lowercase() + } + + val osKey = when { + "win" in osName -> "windows" + "mac" in osName || "darwin" in osName -> "macos" + "nux" in osName || "linux" in osName -> { + val libcOverride = (System.getenv("TARGETLIBC") + ?: project.findProperty("targetLibc")?.toString())?.lowercase() + val isMusl = when (libcOverride) { + "musl" -> true + "gnu", "glibc" -> false + else -> if (targetPlatform != null) false else runCatching { + val libDir = File("/lib") + libDir.exists() && (libDir.listFiles()?.any { f -> f.name.startsWith("ld-musl-") } == true) + }.getOrElse { + runCatching { File("/proc/self/maps").readText().contains("musl") }.getOrDefault(false) + } + } + if (isMusl) "linux-musl" else "linux" + } + else -> error("Unsupported OS: $osName") + } + + val archKey = when (arch) { + "x86_64", "amd64" -> "x86_64" + "aarch64", "arm64" -> "aarch64" + else -> error("Unsupported architecture: $arch") + } + + return "$osKey-$archKey" +} + configurations { compileOnly { extendsFrom(configurations.annotationProcessor.get()) @@ -133,12 +187,14 @@ dependencies { implementation("com.twelvemonkeys.imageio:imageio-bmp:3.13.1") // epub4j-grimmory fork publishes as org.grimmory:epub4j-core - val epub4jCoords = if (useLocalLibs) "org.grimmory:epub4j-core:+" else "org.grimmory:epub4j-core:1.2.0" + val epub4jCoords = if (useLocalLibs) "org.grimmory:epub4j-core:+" else "org.grimmory:epub4j-core:1.4.0" implementation(epub4jCoords) // epub4j-native for native archive parsing - val epub4jNativeCoords = if (useLocalLibs) "org.grimmory:epub4j-native:+" else "org.grimmory:epub4j-native:1.2.0" + val epub4jNativeVersion = "1.4.0" + val epub4jNativeCoords = if (useLocalLibs) "org.grimmory:epub4j-native:+" else "org.grimmory:epub4j-native:$epub4jNativeVersion" implementation(epub4jNativeCoords) + runtimeOnly("$epub4jNativeCoords:${epub4jNativesClassifier()}") // --- Audio Metadata (Audiobook Support) --- implementation("com.github.RouHim:jaudiotagger:2.0.19") diff --git a/backend/gradle.lockfile b/backend/gradle.lockfile index 814da36a7..2b17e06c1 100644 --- a/backend/gradle.lockfile +++ b/backend/gradle.lockfile @@ -82,8 +82,8 @@ org.freemarker:freemarker:2.3.34=compileClasspath,productionRuntimeClasspath,run org.glassfish.jaxb:jaxb-core:4.0.6=productionRuntimeClasspath,runtimeClasspath,testRuntimeClasspath org.glassfish.jaxb:jaxb-runtime:4.0.8=productionRuntimeClasspath,runtimeClasspath,testRuntimeClasspath org.glassfish.jaxb:txw2:4.0.6=productionRuntimeClasspath,runtimeClasspath,testRuntimeClasspath -org.grimmory:epub4j-core:1.2.0=compileClasspath,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.grimmory:epub4j-native:1.2.0=compileClasspath,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.grimmory:epub4j-core:1.4.0=compileClasspath,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.grimmory:epub4j-native:1.4.0=compileClasspath,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.grimmory:pdfium4j:0.16.0=compileClasspath,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.hamcrest:hamcrest:3.0=testCompileClasspath,testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.2.2=productionRuntimeClasspath,runtimeClasspath,testRuntimeClasspath