square / square/square-java-sdk
Maven builds get an empty okhttp jar
Nessuno ha ancora preso questa issue.
- Lingua principale
- Java
- Stelle
- 70
- Fork
- 37
- Merge medio
- 2h 7m
- PR unite (30g)
- 1
Descrizione
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.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Riproduci il problema con la dichiarazione della dipendenza Maven presente nell’issue e ispeziona il POM pubblicato e le relative dipendenze transitive. Usa lo stack trace di ClientOptions.builder come punto di partenza; il lavoro è completato quando i consumer Maven ricevono okhttp-jvm transitivamente e non riscontrano più ClassNotFoundException per okhttp3.Interceptor.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- java, kotlin
- Ambito
- build-system
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 68/100