-
Notifications
You must be signed in to change notification settings - Fork 472
/
build.gradle.kts
56 lines (49 loc) · 1.42 KB
/
build.gradle.kts
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
51
52
53
54
55
import java.io.FileInputStream
import java.io.FileOutputStream
buildscript {
extra["kotlin_version"] = Constants.kotlinVersion
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.1")
classpath(kotlin("gradle-plugin", version = Constants.kotlinVersion))
}
}
tasks {
wrapper {
gradleVersion = "7.0.2"
distributionType = Wrapper.DistributionType.ALL
}
}
allprojects {
repositories {
google()
maven("https://jitpack.io")
mavenCentral()
}
}
tasks.register<Delete>("clean") {
delete(rootProject.buildDir)
val tempAssets = File(projectDir, "/src/main/assets-temp")
if (tempAssets.exists()) {
println("cleaning encrypted assets...")
val encryptedAssets = File(projectDir, "src/main/assets")
encryptedAssets.delete()
tempAssets.listFiles()?.filter { it.isFile }?.forEach { file ->
val fis = FileInputStream(file)
val fo = File(file.absolutePath.replace("assets-temp", "assets"))
fo.parentFile.mkdirs()
val fos = FileOutputStream(fo)
val buffer = ByteArray(4096)
var n: Int
while (fis.read(buffer).also { n = it } != -1) {
fos.write(buffer, 0, n)
}
fis.close()
fos.close()
}
tempAssets.delete()
}
}