Skip to content

Commit 9153d6c

Browse files
authored
Alternate approach to handling okhttp/okhttp-jvm dependency (#7681)
1 parent 28cd73b commit 9153d6c

File tree

6 files changed

+17
-10
lines changed

6 files changed

+17
-10
lines changed

buildSrc/src/main/kotlin/otel.publish-conventions.gradle.kts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ publishing {
3232
name.set("OpenTelemetry Java")
3333
url.set("https://github.com/open-telemetry/opentelemetry-java")
3434

35+
withXml {
36+
// Since 5.0 okhttp uses gradle metadata to choose either okhttp-jvm or okhttp-android.
37+
// This does not work for maven builds that don't understand gradle metadata. They end up
38+
// using the okhttp artifact that is an empty jar. Here we replace usages of okhttp with
39+
// okhttp-jvm so that maven could get the actual okhttp dependency instead of the empty jar.
40+
var result = asString()
41+
var modified = result.toString().replace(">okhttp<", ">okhttp-jvm<")
42+
result.clear()
43+
result.append(modified)
44+
}
45+
3546
licenses {
3647
license {
3748
name.set("The Apache License, Version 2.0")

dependencyManagement/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ val DEPENDENCIES = listOf(
7373
"com.google.code.findbugs:jsr305:3.0.2",
7474
"com.google.guava:guava-beta-checker:1.0",
7575
"com.sun.net.httpserver:http:20070405",
76-
"com.squareup.okhttp3:okhttp-jvm:$okhttpVersion",
76+
"com.squareup.okhttp3:okhttp:$okhttpVersion",
7777
"com.tngtech.archunit:archunit-junit5:1.4.1",
7878
"com.uber.nullaway:nullaway:0.12.10",
7979
"edu.berkeley.cs.jqf:jqf-fuzz:1.7", // jqf-fuzz version 1.8+ requires Java 11+

exporters/otlp/all/build.gradle.kts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ dependencies {
3434
jmhImplementation("com.linecorp.armeria:armeria")
3535
jmhImplementation("com.linecorp.armeria:armeria-grpc")
3636
jmhImplementation("io.opentelemetry.proto:opentelemetry-proto")
37-
jmhRuntimeOnly("com.squareup.okhttp3:okhttp-jvm")
37+
jmhRuntimeOnly("com.squareup.okhttp3:okhttp")
3838
jmhRuntimeOnly("io.grpc:grpc-netty")
3939
}
4040

@@ -64,12 +64,8 @@ testing {
6464
}
6565
}
6666
}
67-
if (it.equals("LATEST")) {
68-
implementation("com.squareup.okhttp3:okhttp-jvm")
69-
} else {
70-
implementation("com.squareup.okhttp3:okhttp")
71-
}
7267

68+
implementation("com.squareup.okhttp3:okhttp")
7369
implementation("io.grpc:grpc-stub")
7470
}
7571

exporters/otlp/testing-internal/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ dependencies {
2727

2828
api("io.opentelemetry.proto:opentelemetry-proto")
2929
api("org.junit.jupiter:junit-jupiter-api")
30-
implementation("com.squareup.okhttp3:okhttp-jvm")
30+
implementation("com.squareup.okhttp3:okhttp")
3131
implementation("org.junit.jupiter:junit-jupiter-params")
3232

3333
implementation("com.linecorp.armeria:armeria-grpc-protocol")

exporters/sender/okhttp/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies {
1212
implementation(project(":exporters:common"))
1313
implementation(project(":sdk:common"))
1414

15-
implementation("com.squareup.okhttp3:okhttp-jvm")
15+
implementation("com.squareup.okhttp3:okhttp")
1616

1717
compileOnly("io.grpc:grpc-stub")
1818
compileOnly("com.fasterxml.jackson.core:jackson-core")

sdk-extensions/jaeger-remote-sampler/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies {
2020
implementation(project(":exporters:common"))
2121
implementation(project(":exporters:sender:okhttp"))
2222

23-
implementation("com.squareup.okhttp3:okhttp-jvm")
23+
implementation("com.squareup.okhttp3:okhttp")
2424

2525
compileOnly("io.grpc:grpc-api")
2626
compileOnly("io.grpc:grpc-protobuf")

0 commit comments

Comments
 (0)