Skip to content

Commit 9b0711f

Browse files
committed
Provide uber-jar containing relocated copy of ASM
To be used in situations when the class-path has an incompatible version of ASM
1 parent 9dfd920 commit 9b0711f

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

build.gradle.kts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
java
33
`maven-publish`
44
signing
5+
id("com.gradleup.shadow")
56
id("pl.allegro.tech.build.axion-release")
67
id("io.github.gradle-nexus.publish-plugin")
78
}
@@ -63,6 +64,16 @@ tasks.named<Jar>("sourcesJar") {
6364
from(allSources())
6465
}
6566

67+
// produce "-all" jar with a shaded copy of ASM
68+
tasks.shadowJar {
69+
dependsOn(embed)
70+
from(embed.map { zipTree(it) })
71+
relocate("org.objectweb.asm", "datadog.instrument.asm")
72+
}
73+
tasks.assemble {
74+
dependsOn(tasks.shadowJar)
75+
}
76+
6677
publishing {
6778
publications {
6879
create<MavenPublication>("maven") {
@@ -89,6 +100,16 @@ publishing {
89100
developerConnection = "scm:[email protected]:datadog/dd-instrument-java.git"
90101
url = "https://github.com/datadog/dd-instrument-java"
91102
}
103+
withXml {
104+
// mark ASM dependency as optional
105+
var doc = asElement().ownerDocument
106+
var deps = doc.getElementsByTagName("dependency")
107+
for (i in 0 ..< deps.length) {
108+
var optional = doc.createElement("optional")
109+
optional.textContent = "true"
110+
deps.item(i).appendChild(optional)
111+
}
112+
}
92113
}
93114
}
94115
}

buildSrc/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ repositories {
99
dependencies {
1010
// needed to re-use the 'libs' version catalog between the main project and buildSrc
1111
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
12+
implementation(libs.shadow)
1213
implementation(libs.spotless)
1314
implementation(libs.spotbugs)
1415
implementation(libs.axion.release)

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[versions]
22
asm = "9.9"
3+
shadow = "9.2.2"
34
junit-jupiter = "5.13.4"
45
junit-platform = "1.13.4"
56
assertj = "3.27.5"
@@ -12,6 +13,7 @@ jmh-plugin = "0.7.3"
1213

1314
[libraries]
1415
asm = { module = "org.ow2.asm:asm", version.ref = "asm" }
16+
shadow = { module = "com.gradleup.shadow:shadow-gradle-plugin", version.ref = "shadow" }
1517
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" }
1618
junit-launcher = { module = "org.junit.platform:junit-platform-launcher", version.ref = "junit-platform" }
1719
assertj-core = { module = "org.assertj:assertj-core", version.ref = "assertj" }

0 commit comments

Comments
 (0)