codeflash/codeflash-java-runtime/build.gradle.kts
HeshamHM28 35c0ed4f74 fix: shade all third-party deps in codeflash-runtime JAR to prevent classpath conflicts
Relocate Gson, Kryo, Objenesis, SLF4J, JaCoCo, and ASM under
com.codeflash.shaded.* in both Maven (shade plugin) and Gradle
(shadow plugin). SQLite is left unshaded due to native lib loading.

Also adds jarHell/thirdPartyAudit to the Gradle skip-validation init
script as a defensive measure, and adds Gradle wrapper + syncs JaCoCo
deps to the Gradle build.

Fixes OpenSearch jar-hell failures caused by duplicate com.google.gson
classes between the fat JAR and project dependencies.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 05:07:38 +00:00

72 lines
2.2 KiB
Text

plugins {
java
id("com.gradleup.shadow") version "9.0.0-beta12"
}
group = "com.codeflash"
version = "1.0.0"
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
repositories {
mavenCentral()
}
dependencies {
implementation("com.google.code.gson:gson:2.10.1")
implementation("com.esotericsoftware:kryo:5.6.2")
implementation("org.objenesis:objenesis:3.4")
implementation("org.xerial:sqlite-jdbc:3.45.0.0")
implementation("org.ow2.asm:asm:9.7.1")
implementation("org.ow2.asm:asm-commons:9.7.1")
implementation("org.jacoco:org.jacoco.agent:0.8.13:runtime")
implementation("org.jacoco:org.jacoco.cli:0.8.13:nodeps")
testImplementation("org.junit.jupiter:junit-jupiter:5.10.1")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
tasks.test {
useJUnitPlatform()
jvmArgs(
"--add-opens", "java.base/java.util=ALL-UNNAMED",
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
"--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED",
"--add-opens", "java.base/java.math=ALL-UNNAMED",
"--add-opens", "java.base/java.io=ALL-UNNAMED",
"--add-opens", "java.base/java.net=ALL-UNNAMED",
"--add-opens", "java.base/java.time=ALL-UNNAMED",
)
}
tasks.shadowJar {
archiveBaseName.set("codeflash-runtime")
archiveVersion.set("1.0.0")
archiveClassifier.set("")
relocate("org.objectweb.asm", "com.codeflash.shaded.org.objectweb.asm")
relocate("com.google.gson", "com.codeflash.shaded.com.google.gson")
relocate("com.esotericsoftware", "com.codeflash.shaded.com.esotericsoftware")
relocate("org.objenesis", "com.codeflash.shaded.org.objenesis")
relocate("org.slf4j", "com.codeflash.shaded.org.slf4j")
relocate("org.jacoco", "com.codeflash.shaded.org.jacoco")
manifest {
attributes(
"Main-Class" to "com.codeflash.Comparator",
"Premain-Class" to "com.codeflash.profiler.ProfilerAgent",
"Can-Retransform-Classes" to "true",
)
}
exclude("META-INF/*.SF")
exclude("META-INF/*.DSA")
exclude("META-INF/*.RSA")
}
tasks.build {
dependsOn(tasks.shadowJar)
}