Maven builds get an empty okhttp jar
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 68/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Lĩnh vực
- build-system
Hướng nghiên cứu
Tái hiện lỗi với khai báo dependency Maven trong issue và kiểm tra POM đã được phát hành cùng các dependency bắc cầu của nó. Sử dụng stack trace của ClientOptions.builder làm điểm bắt đầu; công việc được xem là hoàn tất khi các consumer Maven nhận được okhttp-jvm theo cách bắc cầu và không còn gặp ClassNotFoundException đối với okhttp3.Interceptor.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Java
- Star
- 70
- Fork
- 37
- Merge trung bình
- 2 giờ 7 phút
- Pull request đã merge (30 ngày)
- 1
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
elastic/gradle-plugins#157 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
cryptomator/hub#497 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
johanhaleby/occurrent#1120 ·