Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Maven builds get an empty okhttp jar

Đang mở
#201 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
Công nghệ
java, kotlin
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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.