| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import java.net.URL
- import java.nio.file.Files
- import java.nio.file.StandardCopyOption
- plugins {
- kotlin("android")
- kotlin("kapt")
- id("com.android.application")
- }
- dependencies {
- compileOnly(project(":hideapi"))
- implementation(project(":core"))
- implementation(project(":service"))
- implementation(project(":design"))
- implementation(project(":common"))
- implementation(libs.kotlin.coroutine)
- implementation(libs.androidx.core)
- implementation(libs.androidx.activity)
- implementation(libs.androidx.fragment)
- implementation(libs.androidx.appcompat)
- implementation(libs.androidx.coordinator)
- implementation(libs.androidx.recyclerview)
- implementation(libs.google.material)
- }
- 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))
- }
|