From 2361ffb2721cb8f7289e1481df7efb8be6842aed Mon Sep 17 00:00:00 2001 From: laforetbrut Date: Wed, 22 Apr 2026 06:46:24 +0200 Subject: [PATCH] jarJar: declare version ranges for MySQL + HikariCP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enables co-installation with arcadia-lib2 which embeds HikariCP in [5.1.0, 6.0.0) mysql-connector-j in [8.3.0, 9.0.0) Before: PlayerSync declared its embedded libs with no range, only the exact version (9.3.0 / 5.1.0). When another mod declared a range that did not include our exact version, NeoForge's jarJar resolver had no valid overlap and would either refuse to load or arbitrary-pick one version, risking runtime breakage. After: - mysql-connector-j: strictly [8.3.0, 10.0.0), prefer 9.3.0. Intersects arcadia-lib's [8.3.0, 9.0.0) — resolver picks 8.3.0 when both mods are present. 8.3.0 and 9.3.0 share the same Connection / PreparedStatement / ResultSet APIs we actually use, so downgrade is safe. - HikariCP: strictly [5.1.0, 6.0.0), prefer 5.1.0. Identical to arcadia-lib's declared range — shared single instance. No code changes — only the metadata shipped in META-INF/jarjar/metadata.json. Verified via unzip -p that the range is correctly emitted. --- build.gradle | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 2d70645..7e0a439 100644 --- a/build.gradle +++ b/build.gradle @@ -137,17 +137,32 @@ dependencies { runtimeOnly "curse.maven:curios-309927:6529130" runtimeOnly "curse.maven:sophisticated-backpacks-422301:7169832" runtimeOnly "curse.maven:sophisticated-core-618298:7168230" - // embedd the JDBC driver in the mod using jarJar + // Embed the JDBC driver in the mod using jarJar. + // FIX COMPAT: declare a version RANGE so multi-mod setups (eg. arcadia-lib which + // requires [8.3.0, 9.0.0)) can resolve a single shared MySQL driver instance + // without jarJar complaining about incompatible constraints. The `prefer` keeps + // 9.3.0 as our baseline when PlayerSync is the only consumer. runtimeOnly "com.mysql:mysql-connector-j:${jdbc_version}" - jarJar "com.mysql:mysql-connector-j:${jdbc_version}" + jarJar("com.mysql:mysql-connector-j") { + version { + strictly "[8.3.0, 10.0.0)" + prefer "${jdbc_version}" + } + } additionalRuntimeClasspath "com.mysql:mysql-connector-j:${jdbc_version}" // HikariCP connection pool — eliminates isValid() ping on every query (no more pingInternal in Spark) - // Exclude slf4j-api: NeoForge already ships it + // Exclude slf4j-api: NeoForge already ships it. + // FIX COMPAT: declare a range matching arcadia-lib's [5.1.0, 6.0.0) so jarJar + // resolution succeeds with a single shared instance. implementation("com.zaxxer:HikariCP:${hikari_version}") { exclude group: "org.slf4j", module: "slf4j-api" } - jarJar("com.zaxxer:HikariCP:${hikari_version}") { + jarJar("com.zaxxer:HikariCP") { + version { + strictly "[5.1.0, 6.0.0)" + prefer "${hikari_version}" + } exclude group: "org.slf4j", module: "slf4j-api" } additionalRuntimeClasspath("com.zaxxer:HikariCP:${hikari_version}") {