File tree 1 file changed +32
-9
lines changed
1 file changed +32
-9
lines changed Original file line number Diff line number Diff line change
1
+ import groovy.json.JsonSlurper
2
+
3
+
1
4
buildscript {
2
5
ext. kotlin_version = ' 1.3.61'
6
+
7
+ def connection = new URL (' https://api.ip.sb/geoip' ). openConnection()
8
+ connection. setRequestMethod(' GET' )
9
+ def reader = new BufferedReader (new InputStreamReader (connection. inputStream))
10
+ def text = reader. readLine()
11
+
12
+ def slurper = new JsonSlurper ()
13
+ def states = slurper. parseText(text)
14
+ def country = states[' country' ]
15
+
16
+ def isChina = country == ' China'
17
+
18
+ ext. isChina = isChina
19
+
3
20
repositories {
4
- google()
5
- jcenter()
6
- maven { url ' https://maven.aliyun.com/repository/google' }
7
- maven { url ' https://maven.aliyun.com/repository/jcenter' }
21
+ if (isChina) {
22
+ maven { url ' https://maven.aliyun.com/repository/google' }
23
+ maven { url ' https://maven.aliyun.com/repository/jcenter' }
24
+ } else {
25
+ google()
26
+ jcenter()
27
+ }
8
28
}
9
29
10
30
dependencies {
@@ -15,10 +35,13 @@ buildscript {
15
35
16
36
allprojects {
17
37
repositories {
18
- google()
19
- jcenter()
20
- maven { url ' https://maven.aliyun.com/repository/google' }
21
- maven { url ' https://maven.aliyun.com/repository/jcenter' }
38
+ if (isChina) {
39
+ maven { url ' https://maven.aliyun.com/repository/google' }
40
+ maven { url ' https://maven.aliyun.com/repository/jcenter' }
41
+ } else {
42
+ google()
43
+ jcenter()
44
+ }
22
45
}
23
46
}
24
47
@@ -43,4 +66,4 @@ subprojects {
43
66
}
44
67
}
45
68
}
46
- }
69
+ }
You can’t perform that action at this time.
0 commit comments