87 lines
2.5 KiB
Groovy
87 lines
2.5 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/go_output/native_library"]
|
|
java.srcDirs += ["$buildDir/intermediates/go_output/generate_java"]
|
|
}
|
|
}
|
|
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 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)
|
|
}
|
|
|
|
def gs = tasks.register("golangBind", GolangBindTask.class)
|
|
|
|
preBuild.dependsOn(gs)
|
|
}
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
} |