File tree 3 files changed +44
-1
lines changed
core/src/main/kotlin/androidx/build/gradle/core
3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2024 The Android Open Source Project
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ package androidx.build.gradle.core
19
+
20
+ import okhttp3.Interceptor
21
+ import okhttp3.Response
22
+ import org.gradle.api.GradleException
23
+ import java.io.IOException
24
+
25
+ class NetworkErrorInterceptor : Interceptor {
26
+ override fun intercept (chain : Interceptor .Chain ): Response {
27
+ val request = chain.request()
28
+ return try {
29
+ chain.proceed(request)
30
+ } catch (ex: IOException ) {
31
+ throw GradleException (" There seems to be some issue with the network access. " +
32
+ " Please check your internet access or use --offline with your gradle commands to continue working" +
33
+ " without accessing network resources." )
34
+ }
35
+ }
36
+ }
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ package androidx.build.gradle.core
19
19
20
20
import com.google.gson.Gson
21
21
import com.google.gson.GsonBuilder
22
+ import okhttp3.OkHttpClient
22
23
import retrofit2.Call
23
24
import retrofit2.Retrofit
24
25
import retrofit2.converter.gson.GsonConverterFactory
@@ -37,9 +38,15 @@ interface TokenInfoService {
37
38
38
39
companion object {
39
40
fun tokenService (): TokenInfoService {
41
+ val httpClient = OkHttpClient
42
+ .Builder ()
43
+ .addInterceptor(NetworkErrorInterceptor ())
44
+ .build()
45
+
40
46
val retrofit = Retrofit .Builder ()
41
47
.baseUrl(" https://www.googleapis.com" )
42
48
.addConverterFactory(GsonConverterFactory .create(gson()))
49
+ .client(httpClient)
43
50
.build()
44
51
45
52
return retrofit.create()
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ gradlePlugin {
58
58
}
59
59
60
60
group = " androidx.build.gradle.gcpbuildcache"
61
- version = " 1.0.0-beta09 "
61
+ version = " 1.0.0-beta10 "
62
62
63
63
testing {
64
64
suites {
You can’t perform that action at this time.
0 commit comments