-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.gradle
50 lines (48 loc) · 1.94 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.jetbrainsKotlinAndroid) apply false
alias(libs.plugins.googleDevtoolsKsp) apply false
alias(libs.plugins.kotlinParcelize) apply false
}
tasks.register('summary') {
def download = { name, host ->
println "==========$name summary==========="
def folder = new File("app/src/$name/assets")
def fileEtag = new File("$folder/summary.etag")
def etag = null
if (fileEtag.exists()) etag = fileEtag.readLines().join('')
def src = "https://$host/tag/summary.json"
def url = new URL(src)
def connection = (HttpURLConnection) url.openConnection()
try {
connection.connectTimeout = 1000 * 5
connection.readTimeout = 1000 * 60
connection.useCaches = true
if (etag != null && etag != '') connection.setRequestProperty('if-none-match', etag)
connection.connect()
println "${connection.getResponseCode()}: ${connection.getResponseMessage()}"
if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED) return
def fileJson = new File("$folder/summary.json")
connection.inputStream.withReader { i -> fileJson.withOutputStream { it << i } }
def newEtag = connection.getHeaderField("ETag")
println "etag: $etag -> $newEtag"
if (newEtag != null && newEtag != '') fileEtag.withOutputStream { it << newEtag }
} catch (Exception e) {
println e.message
} finally {
connection.disconnect()
}
}
doLast {
download("konachan", "konachan.com")
download("yande", "yande.re")
println 'summary'
}
}
tasks.register('publish') {
dependsOn 'app:assembleRelease'
doLast {
println 'publish'
}
}