apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {
    compileSdkVersion 28
    buildToolsVersion "30.0.3"
    ndkVersion "25.1.8937393"
    defaultConfig {
        applicationId "org.sdrpp.sdrpp"
        minSdkVersion 28
        targetSdkVersion 28
        versionCode 1
        versionName "1.2.0"

        externalNativeBuild {
            cmake {
                arguments "-DOPT_BACKEND_GLFW=OFF", "-DOPT_BACKEND_ANDROID=ON", "-DOPT_BUILD_SOAPY_SOURCE=OFF", "-DOPT_BUILD_ANDROID_AUDIO_SINK=ON", "-DOPT_BUILD_AUDIO_SINK=OFF", "-DOPT_BUILD_DISCORD_PRESENCE=OFF", "-DOPT_BUILD_M17_DECODER=ON", "-DOPT_BUILD_PLUTOSDR_SOURCE=ON", "-DOPT_BUILD_AUDIO_SOURCE=OFF"
            }
        }
    }

    signingConfigs {
        debug {
            storeFile file("debug.keystore")
            storePassword "android"
            keyAlias "androiddebugkey"
            keyPassword "android"
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt')
        }
        debug {
            signingConfig signingConfigs.debug
        }
    }

    externalNativeBuild {
        cmake {
            version "3.18.1"
            path "../../CMakeLists.txt"
        }
    }

    sourceSets {
        main {
            assets.srcDirs += ['assets']
        }
    }
}

task deleteTempAssets (type: Delete) {
    delete 'assets'
}

task copyResources(type: Copy) {
    description = 'Copy resources...'
    from '../../root/'
    into 'assets/'
    include('**/*')
}

repositories {
    mavenCentral()
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.2'
}

copyResources.dependsOn deleteTempAssets
preBuild.dependsOn copyResources