Skip to content

Commit 1786dd7

Browse files
authored
Merge okhttp-android into okhttp (#8635)
* Merge okhttp-android into okhttp. Since :okhttp is kmp, it isn't required to be separate. And also the okhttp-android/jvm artifact naming conflicts with it.
1 parent b669048 commit 1786dd7

File tree

24 files changed

+67
-187
lines changed

24 files changed

+67
-187
lines changed

.github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ jobs:
518518
uses: gradle/actions/setup-gradle@v4
519519

520520
- name: Gradle cache
521-
run: ./gradlew -PandroidBuild=true :okhttp-android:test
521+
run: ./gradlew -PandroidBuild=true :android-test:test
522522

523523
- name: AVD cache
524524
uses: actions/cache@v4
@@ -545,7 +545,7 @@ jobs:
545545
with:
546546
api-level: ${{ matrix.api-level }}
547547
arch: ${{ matrix.api-level == '34' && 'x86_64' || 'x86' }}
548-
script: ./gradlew -PandroidBuild=true :okhttp-android:connectedCheck :android-test:connectedCheck
548+
script: ./gradlew -PandroidBuild=true :android-test:connectedCheck
549549
env:
550550
API_LEVEL: ${{ matrix.api-level }}
551551

android-test-app/build.gradle.kts

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ android {
4141
dependencies {
4242
implementation(libs.playservices.safetynet)
4343
implementation(projects.okhttp)
44-
implementation(projects.okhttpAndroid)
4544
implementation(libs.androidx.activity)
4645

4746
androidTestImplementation(libs.androidx.junit)

android-test/build.gradle.kts

+15-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,20 @@ dependencies {
6161
implementation(libs.kotlin.reflect)
6262
implementation(libs.playservices.safetynet)
6363
implementation(projects.okhttp)
64-
implementation(projects.okhttpAndroid)
64+
65+
testImplementation(libs.junit)
66+
testImplementation(libs.junit.ktx)
67+
testImplementation(libs.assertk)
68+
testImplementation(projects.okhttpTls)
69+
testImplementation(projects.loggingInterceptor)
70+
testImplementation(libs.androidx.test.runner)
71+
testImplementation(libs.robolectric)
72+
testImplementation(libs.androidx.espresso.core)
73+
testImplementation(libs.squareup.okio.fakefilesystem)
74+
testImplementation(projects.okhttpTestingSupport)
75+
testImplementation(rootProject.libs.conscrypt.openjdk)
76+
testImplementation(rootProject.libs.junit.jupiter.engine)
77+
testImplementation(rootProject.libs.junit.vintage.engine)
6578

6679
androidTestImplementation(projects.okhttpTestingSupport) {
6780
exclude("org.openjsse", "openjsse")
@@ -72,13 +85,13 @@ dependencies {
7285
androidTestImplementation(libs.bouncycastle.bcprov)
7386
androidTestImplementation(libs.bouncycastle.bctls)
7487
androidTestImplementation(libs.conscrypt.android)
88+
androidTestImplementation(projects.mockwebserver3Junit4)
7589
androidTestImplementation(projects.mockwebserver3Junit5)
7690
androidTestImplementation(projects.okhttpBrotli)
7791
androidTestImplementation(projects.okhttpDnsoverhttps)
7892
androidTestImplementation(projects.loggingInterceptor)
7993
androidTestImplementation(projects.okhttpSse)
8094
androidTestImplementation(projects.okhttpTls)
81-
androidTestImplementation(projects.okhttpAndroid)
8295
androidTestImplementation(libs.androidx.junit)
8396
androidTestImplementation(libs.androidx.espresso.core)
8497
androidTestImplementation(libs.httpClient5)

okhttp-android/src/androidTest/kotlin/okhttp3/android/AndroidAsyncDnsTest.kt android-test/src/androidTest/java/okhttp/android/test/AndroidAsyncDnsTest.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*
1616
*/
17-
package okhttp3.android
17+
package okhttp.android.test
1818

1919
import android.content.Context
2020
import android.net.ConnectivityManager
@@ -36,6 +36,7 @@ import okhttp3.AsyncDns
3636
import okhttp3.HttpUrl.Companion.toHttpUrl
3737
import okhttp3.OkHttpClient
3838
import okhttp3.Request
39+
import okhttp3.android.AndroidAsyncDns
3940
import okhttp3.tls.HandshakeCertificates
4041
import okhttp3.tls.HeldCertificate
4142
import okio.IOException

android-test/src/main/AndroidManifest.xml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
xmlns:tools="http://schemas.android.com/tools" package="okhttp.android.test">
33

44
<uses-permission android:name="android.permission.INTERNET" />
5+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
56

67
<application android:usesCleartextTraffic="true" tools:targetApi="m"/>
78

okhttp-android/src/test/kotlin/okhttp3/android/AndroidAsyncDnsTest.kt android-test/src/test/kotlin/okhttp/android/test/AndroidAsyncDnsTest.kt

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package okhttp3.android
16+
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
17+
18+
package okhttp.android.test
1719

1820
import assertk.assertFailure
1921
import assertk.assertions.hasMessage
2022
import assertk.assertions.isInstanceOf
2123
import java.net.UnknownHostException
2224
import okhttp3.AsyncDns
25+
import okhttp3.android.AndroidAsyncDns
2326
import org.junit.Test
2427
import org.junit.runner.RunWith
2528
import org.robolectric.RobolectricTestRunner

okhttp-android/src/test/kotlin/okhttp3/android/AndroidLoggingTest.kt android-test/src/test/kotlin/okhttp/android/test/AndroidLoggingTest.kt

+9-11
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*
1616
*/
17-
package okhttp3.android
17+
package okhttp.android.test
1818

1919
import android.util.Log
2020
import assertk.assertThat
@@ -26,6 +26,7 @@ import okhttp3.ConnectionSpec
2626
import okhttp3.HttpUrl.Companion.toHttpUrl
2727
import okhttp3.OkHttpClient
2828
import okhttp3.Request
29+
import okhttp3.internal.platform.AndroidPlatform
2930
import okhttp3.logging.HttpLoggingInterceptor
3031
import okhttp3.logging.LoggingEventListener
3132
import org.junit.Test
@@ -36,18 +37,16 @@ import org.robolectric.shadows.ShadowLog
3637
@RunWith(RobolectricTestRunner::class)
3738
class AndroidLoggingTest {
3839
val clientBuilder =
39-
OkHttpClient.Builder()
40-
.connectionSpecs(listOf(ConnectionSpec.CLEARTEXT))
41-
.dns {
42-
throw UnknownHostException("shortcircuit")
43-
}
40+
OkHttpClient.Builder().connectionSpecs(listOf(ConnectionSpec.CLEARTEXT)).dns {
41+
throw UnknownHostException("shortcircuit")
42+
}
4443

4544
val request = Request("http://google.com/robots.txt".toHttpUrl())
4645

4746
@Test
4847
fun testHttpLoggingInterceptor() {
4948
val interceptor =
50-
HttpLoggingInterceptor.androidLogging(tag = "testHttpLoggingInterceptor").apply {
49+
HttpLoggingInterceptor().apply {
5150
level = HttpLoggingInterceptor.Level.BASIC
5251
}
5352

@@ -59,7 +58,7 @@ class AndroidLoggingTest {
5958
// expected
6059
}
6160

62-
val logs = ShadowLog.getLogsForTag("testHttpLoggingInterceptor")
61+
val logs = ShadowLog.getLogsForTag(AndroidPlatform.Tag)
6362
assertThat(logs.map { it.type }).containsOnly(Log.INFO)
6463
assertThat(logs.map { it.msg }).containsExactly(
6564
"--> GET http://google.com/robots.txt",
@@ -71,16 +70,15 @@ class AndroidLoggingTest {
7170

7271
@Test
7372
fun testLoggingEventListener() {
74-
val client =
75-
clientBuilder.eventListenerFactory(LoggingEventListener.androidLogging(tag = "testLoggingEventListener")).build()
73+
val client = clientBuilder.eventListenerFactory(LoggingEventListener.Factory()).build()
7674

7775
try {
7876
client.newCall(request).execute()
7977
} catch (uhe: UnknownHostException) {
8078
// expected
8179
}
8280

83-
val logs = ShadowLog.getLogsForTag("testLoggingEventListener")
81+
val logs = ShadowLog.getLogsForTag(AndroidPlatform.Tag)
8482
assertThat(logs.map { it.type }).containsOnly(Log.INFO)
8583
assertThat(
8684
logs.map {

okhttp-android/src/test/kotlin/okhttp3/android/AndroidSocketAdapterTest.kt android-test/src/test/kotlin/okhttp/android/test/AndroidSocketAdapterTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package okhttp3.android
16+
package okhttp.android.test
1717

1818
import java.security.Provider
1919
import javax.net.ssl.SSLContext

okhttp-android/src/test/kotlin/okhttp3/android/RobolectricOkHttpClientTest.kt android-test/src/test/kotlin/okhttp/android/test/RobolectricOkHttpClientTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*
1616
*/
17-
package okhttp3.android
17+
package okhttp.android.test
1818

1919
import android.app.Application
2020
import android.content.Context

okhttp-android/src/test/kotlin/okhttp3/android/ShadowDnsResolver.kt android-test/src/test/kotlin/okhttp/android/test/ShadowDnsResolver.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package okhttp3.android
16+
package okhttp.android.test
1717

1818
import android.net.DnsResolver
1919
import android.net.Network

okhttp-android/Module.md

-3
This file was deleted.

okhttp-android/README.md

-13
This file was deleted.

okhttp-android/api/okhttp-android.api

-19
This file was deleted.

okhttp-android/build.gradle.kts

-82
This file was deleted.

okhttp-android/src/androidTest/AndroidManifest.xml

-6
This file was deleted.

okhttp-android/src/main/AndroidManifest.xml

-6
This file was deleted.

okhttp-android/src/main/kotlin/okhttp3/android/AndroidLogging.kt

-36
This file was deleted.

okhttp/api/android/okhttp.api

+12
Original file line numberDiff line numberDiff line change
@@ -1292,3 +1292,15 @@ public abstract class okhttp3/WebSocketListener {
12921292
public fun onOpen (Lokhttp3/WebSocket;Lokhttp3/Response;)V
12931293
}
12941294

1295+
public final class okhttp3/android/AndroidAsyncDns : okhttp3/AsyncDns {
1296+
public static final field Companion Lokhttp3/android/AndroidAsyncDns$Companion;
1297+
public fun <init> (Lokhttp3/AsyncDns$DnsClass;Landroid/net/Network;)V
1298+
public synthetic fun <init> (Lokhttp3/AsyncDns$DnsClass;Landroid/net/Network;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
1299+
public fun query (Ljava/lang/String;Lokhttp3/AsyncDns$Callback;)V
1300+
}
1301+
1302+
public final class okhttp3/android/AndroidAsyncDns$Companion {
1303+
public final fun getIPv4 ()Lokhttp3/android/AndroidAsyncDns;
1304+
public final fun getIPv6 ()Lokhttp3/android/AndroidAsyncDns;
1305+
}
1306+

0 commit comments

Comments
 (0)