apply plugin: 'com.android.application'

dependencies {
   implementation files('../../../lib/facerec.jar')
   implementation "androidx.core:core:1.0.0"
}

android {
    compileSdkVersion 30
    buildToolsVersion "29.0.2"

    defaultConfig {
        applicationId "com.vdt.face_recognition.video_recognition_demo"
        minSdkVersion 18
        targetSdkVersion 30
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    sourceSets {
        main {
            jniLibs.srcDirs = ["../../../lib"]
        }
    }


//Insert unique string into asest to avoid copy assets to data folder every time on load app.
//Checking this unique string in UnpackAssetsActivity
    task computeAssetsHash() {
        doLast {
            mkdir("$projectDir/src/main/assets/")
            new File(  "$projectDir/src/main/assets/", "assets-hash.txt").text = 
                """Buildtime: ${new Date().format("YYYY:MM:dd:HH:mm:ss", TimeZone.getTimeZone("GMT"))}"""
        }
    }


    task copyFiles(type: Copy) {
        description = 'Copy files'
        from("$projectDir/../../.."){
            include (
                "conf/**",
                "share/fda/**",
                "share/facedetectors/blf/**",
                "share/quality/**",
                "share/quality_iso/**",
                "share/face_quality/**",
                "share/facerec/recognizers/method12v30/**",
                "share/facerec/recognizers/method12v50/**",
                "share/facerec/recognizers/method12v100/**",
                "share/faceattributes/**",
                "share/faceanalysis/**",
                "license/**"
            )
            exclude ('share/facerec/recognizers/**/*dt')
        }
        into "$projectDir/src/main/assets/"
    }

    preBuild.dependsOn computeAssetsHash, copyFiles
}
