mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2026-05-09 18:11:26 +08:00
Squashed commit of the following:
commit 574fba87ab733332efa17733a6602a1649e62379 Author: Steve Johnson <stevejohnson1438@proton.me> Date: Sun Oct 29 21:31:23 2023 +0800 support importing local geofile commit ec410293f3abe29835645233349d026d3a55acc0 Author: Steve Johnson <stevejohnson1438@proton.me> Date: Sun Oct 29 17:18:52 2023 +0800 release assets at runtime commit 2dfb95bab98ba661a28efe255e2965c35c6580c4 Author: Steve Johnson <stevejohnson1438@proton.me> Date: Sun Oct 29 16:43:41 2023 +0800 remove embedded country.mmdb commit fb245ed4a3c257284685f3b1bee5d9f7333833ce Author: Steve Johnson <stevejohnson1438@proton.me> Date: Sun Oct 29 16:35:14 2023 +0800 simplity gradle commit 2fb75c87a13dea7e5c8f8f4126cc53d2d6926b99 Author: Steve Johnson <stevejohnson1438@proton.me> Date: Sun Oct 29 16:06:17 2023 +0800 add geofiles download
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
import java.net.URL
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.StandardCopyOption
|
||||
|
||||
plugins {
|
||||
kotlin("android")
|
||||
kotlin("kapt")
|
||||
@@ -25,3 +29,40 @@ dependencies {
|
||||
tasks.getByName("clean", type = Delete::class) {
|
||||
delete(file("release"))
|
||||
}
|
||||
|
||||
val geoFilesDownloadDir = "src/main/assets"
|
||||
|
||||
task("downloadGeoFiles") {
|
||||
|
||||
val geoFilesUrls = mapOf(
|
||||
"https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.metadb" to "geoip.metadb",
|
||||
"https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.dat" to "geosite.dat",
|
||||
// "https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/country.mmdb" to "country.mmdb",
|
||||
)
|
||||
|
||||
doLast {
|
||||
geoFilesUrls.forEach { (downloadUrl, outputFileName) ->
|
||||
val url = URL(downloadUrl)
|
||||
val outputPath = file("$geoFilesDownloadDir/$outputFileName")
|
||||
outputPath.parentFile.mkdirs()
|
||||
url.openStream().use { input ->
|
||||
Files.copy(input, outputPath.toPath(), StandardCopyOption.REPLACE_EXISTING)
|
||||
println("$outputFileName downloaded to $outputPath")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
val downloadGeoFilesTask = tasks["downloadGeoFiles"]
|
||||
|
||||
tasks.forEach {
|
||||
if (it.name.startsWith("assemble")) {
|
||||
it.dependsOn(downloadGeoFilesTask)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.getByName("clean", type = Delete::class) {
|
||||
delete(file(geoFilesDownloadDir))
|
||||
}
|
||||
Reference in New Issue
Block a user