diff --git a/buildSrc/src/main/kotlin/otel.publish-conventions.gradle.kts b/buildSrc/src/main/kotlin/otel.publish-conventions.gradle.kts index 7b922edc8..070edf183 100644 --- a/buildSrc/src/main/kotlin/otel.publish-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/otel.publish-conventions.gradle.kts @@ -57,6 +57,17 @@ publishing { developerConnection.set("scm:git:git@github.com:open-telemetry/opentelemetry-java-contrib.git") url.set("git@github.com:open-telemetry/opentelemetry-java-contrib.git") } + + withXml { + // Since 5.0 okhttp uses gradle metadata to choose either okhttp-jvm or okhttp-android. + // This does not work for maven builds that don't understand gradle metadata. They end up + // using the okhttp artifact that is an empty jar. Here we replace usages of okhttp with + // okhttp-jvm so that maven could get the actual okhttp dependency instead of the empty jar. + var result = asString() + var modified = result.toString().replace(">okhttp<", ">okhttp-jvm<") + result.clear() + result.append(modified) + } } } }