square / square/square-java-sdk

Maven builds get an empty okhttp jar

Open
#201 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
70
Forks
37
Avg merge
2h 7m
Merged PRs (30d)
1

Description

Using

<dependency>
    <groupId>com.squareup</groupId>
    <artifactId>square</artifactId>
    <version>47.0.1.20260715</version>
    <scope>compile</scope>
</dependency>

The resulting jar gets an empty okhttp jar. We now need to add

<dependency>
    <groupId>com.squareup.okhttp3</groupId>
    <artifactId>okhttp-jvm</artifactId>
    <version>5.2.1</version>
</dependency>

for the build to work.

Some additional detail on the failure and root cause:

Symptom — any Maven-built app using SDK 47.x fails at runtime the first time a client is built:

  java.lang.ClassNotFoundException: okhttp3.Interceptor
      at com.squareup.square.core.ClientOptions.builder(ClientOptions.java:102)
      at com.squareup.square.SquareClientBuilder.buildClientOptions(SquareClientBuilder.java:104)
      at com.squareup.square.SquareClientBuilder.build(SquareClientBuilder.java:255)

Root cause — the SDK depends on com.squareup.okhttp3:okhttp 5.x, which is published as a Kotlin Multiplatform artifact. The root okhttp jar on Maven Central contains no classes (just META-INF/kotlin-project-structure-metadata.json); the real JVM classes live in okhttp-jvm.
Gradle resolves the redirect via Gradle Module Metadata, but Maven ignores .module files, so Maven consumers silently get the empty jar.
Per the OkHttp README (https://github.com/square/okhttp#requirements), "Maven projects must select between okhttp-jvm and okhttp-android" — see also square/okhttp#8913.

Suggested fix — declare com.squareup.okhttp3:okhttp-jvm in the SDK's published POM so the correct artifact flows transitively to Maven consumers. This is how OpenTelemetry resolved the identical breakage (open-telemetry/opentelemetry-java#7491), and it matches what okio itself does: okio's root POM declares okio-jvm as a plain compile dependency, which is why okio classes resolve fine under Maven while okhttp's don't.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the Maven dependency declaration in the issue and inspect the published POM and its transitive dependencies. Use the ClientOptions.builder stack trace as the entry point; done means Maven consumers receive okhttp-jvm transitively and no longer hit ClassNotFoundException for okhttp3.Interceptor.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.