Skip to content

Commit 35c0ed4

Browse files
HeshamHM28claude
authored andcommitted
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>
1 parent 3257578 commit 35c0ed4

7 files changed

Lines changed: 296 additions & 3 deletions

File tree

codeflash-java-runtime/build.gradle.kts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ dependencies {
2222
implementation("org.xerial:sqlite-jdbc:3.45.0.0")
2323
implementation("org.ow2.asm:asm:9.7.1")
2424
implementation("org.ow2.asm:asm-commons:9.7.1")
25+
implementation("org.jacoco:org.jacoco.agent:0.8.13:runtime")
26+
implementation("org.jacoco:org.jacoco.cli:0.8.13:nodeps")
2527

2628
testImplementation("org.junit.jupiter:junit-jupiter:5.10.1")
2729
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
@@ -45,7 +47,12 @@ tasks.shadowJar {
4547
archiveVersion.set("1.0.0")
4648
archiveClassifier.set("")
4749

48-
relocate("org.objectweb.asm", "com.codeflash.asm")
50+
relocate("org.objectweb.asm", "com.codeflash.shaded.org.objectweb.asm")
51+
relocate("com.google.gson", "com.codeflash.shaded.com.google.gson")
52+
relocate("com.esotericsoftware", "com.codeflash.shaded.com.esotericsoftware")
53+
relocate("org.objenesis", "com.codeflash.shaded.org.objenesis")
54+
relocate("org.slf4j", "com.codeflash.shaded.org.slf4j")
55+
relocate("org.jacoco", "com.codeflash.shaded.org.jacoco")
4956

5057
manifest {
5158
attributes(
55.6 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

codeflash-java-runtime/gradlew

Lines changed: 176 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codeflash-java-runtime/gradlew.bat

Lines changed: 84 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codeflash-java-runtime/pom.xml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,27 @@
156156
<relocations>
157157
<relocation>
158158
<pattern>org.objectweb.asm</pattern>
159-
<shadedPattern>com.codeflash.asm</shadedPattern>
159+
<shadedPattern>com.codeflash.shaded.org.objectweb.asm</shadedPattern>
160+
</relocation>
161+
<relocation>
162+
<pattern>com.google.gson</pattern>
163+
<shadedPattern>com.codeflash.shaded.com.google.gson</shadedPattern>
164+
</relocation>
165+
<relocation>
166+
<pattern>com.esotericsoftware</pattern>
167+
<shadedPattern>com.codeflash.shaded.com.esotericsoftware</shadedPattern>
168+
</relocation>
169+
<relocation>
170+
<pattern>org.objenesis</pattern>
171+
<shadedPattern>com.codeflash.shaded.org.objenesis</shadedPattern>
172+
</relocation>
173+
<relocation>
174+
<pattern>org.slf4j</pattern>
175+
<shadedPattern>com.codeflash.shaded.org.slf4j</shadedPattern>
176+
</relocation>
177+
<relocation>
178+
<pattern>org.jacoco</pattern>
179+
<shadedPattern>com.codeflash.shaded.org.jacoco</shadedPattern>
160180
</relocation>
161181
</relocations>
162182
<transformers>

codeflash/languages/java/gradle_strategy.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
'checkstyleMain', 'checkstyleTest',
3535
'spotbugsMain', 'spotbugsTest',
3636
'pmdMain', 'pmdTest',
37-
'rat', 'japicmp'
37+
'rat', 'japicmp',
38+
'jarHell', 'thirdPartyAudit'
3839
]
3940
}.configureEach {
4041
enabled = false

0 commit comments

Comments
 (0)