96 lines
2.8 KiB
Groovy
96 lines
2.8 KiB
Groovy
apply plugin: 'com.android.library'
|
|
apply plugin: 'kotlin-android'
|
|
apply plugin: 'kotlin-android-extensions'
|
|
apply plugin: 'kotlinx-serialization'
|
|
|
|
android {
|
|
compileSdkVersion 29
|
|
buildToolsVersion "29.0.2"
|
|
|
|
defaultConfig {
|
|
minSdkVersion 24
|
|
targetSdkVersion 29
|
|
versionCode 1
|
|
versionName "1.0"
|
|
|
|
consumerProguardFiles 'consumer-rules.pro'
|
|
}
|
|
|
|
buildTypes {
|
|
release {
|
|
minifyEnabled false
|
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
}
|
|
}
|
|
|
|
sourceSets {
|
|
main {
|
|
assets.srcDirs += ["$buildDir/intermediates/dynamic_assets"]
|
|
jniLibs.srcDirs += ["$buildDir/intermediates/native_output"]
|
|
}
|
|
}
|
|
compileOptions {
|
|
sourceCompatibility = 1.8
|
|
targetCompatibility = 1.8
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation "androidx.core:core-ktx:1.1.0"
|
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
|
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.14.0"
|
|
}
|
|
|
|
afterEvaluate {
|
|
def compileArch = ["arm64-v8a", "x86_64"]
|
|
def options = new GolangBuildOptions(file("src/main/golang"), file("$buildDir/intermediates/native_output"), "23")
|
|
|
|
def ts = compileArch.stream().map { abi ->
|
|
tasks.register("golangBuildFor" + abi.replace("-", "").replace("_", ""), GolangBuildTask.class) {
|
|
setOptions options, abi
|
|
}
|
|
}.toArray()
|
|
|
|
for ( task in tasks ) {
|
|
if ( task.name.contains("JniLib") )
|
|
task.dependsOn(ts)
|
|
}
|
|
|
|
def ds = tasks.register("downloadMMDB", MMDBDowloadTask.class) {
|
|
onlyIf {
|
|
System.currentTimeMillis() - file("$buildDir/intermediates/cache/Country.tar.gz").lastModified() > 24 * 3600 * 1000L
|
|
}
|
|
|
|
output = "$buildDir/intermediates/cache/Country.tar.gz"
|
|
}
|
|
|
|
def es = tasks.register("extractMMDB", Copy.class) {
|
|
onlyIf {
|
|
file("$buildDir/intermediates/cache/Country.tar.gz").lastModified() > file("$buildDir/intermediates/dynamic_assets/Country.mmdb").lastModified()
|
|
}
|
|
|
|
from(tarTree("$buildDir/intermediates/cache/Country.tar.gz")) {
|
|
include "**/*.mmdb"
|
|
}
|
|
into "$buildDir/intermediates/cache/mmdb"
|
|
|
|
doLast {
|
|
file("$buildDir/intermediates/dynamic_assets").mkdirs()
|
|
fileTree("$buildDir/intermediates/cache/mmdb").visit { FileVisitDetails details ->
|
|
if ( details.path.endsWith("Country.mmdb") )
|
|
details.file.renameTo(file("$buildDir/intermediates/dynamic_assets/Country.mmdb"))
|
|
}
|
|
}
|
|
|
|
dependsOn ds
|
|
}
|
|
|
|
for ( task in tasks ) {
|
|
if ( task.name.contains("generate") && task.name.contains("Assets") )
|
|
task.dependsOn(es)
|
|
}
|
|
}
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
} |