apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'

group = 'com.github.FacePlusPlus'
android {
    compileSdkVersion CompileSdkVersion
    buildToolsVersion BuildToolsVersion
    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 25
        versionCode 1
        versionName "0.5.2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                abiFilters 'armeabi-v7a', 'arm64-v8a'
                arguments "-DANDROID_ARM_NEON=TRUE", "-DANDROID_STL=c++_static"
            }
        }
        project.archivesBaseName = "MGFaceppSDK"
        project.version = android.defaultConfig.versionName
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main {
            jniLibs.srcDirs = ['src/main/jniLibs']
        }
    }

    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"
        }
    }


}

build.mustRunAfter clean

task buildAAR(dependsOn: build) {
    doLast {
        delete '../release'

        copy {
            from "build/outputs/aar/MGFaceppSDK-release.aar"
            //include "*"
            into "../release"
            rename{
                String fileName->
                    "${archivesBaseName}-${version}.aar"
            }
        }

        delete "../faceppdemo/libs/${archivesBaseName}-${version}.aar"

        copy {
            from "../release/${archivesBaseName}-${version}.aar"
            //include "*"
            into "../faceppdemo/libs"
        }


        println "build arr successful"
    }

}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testCompile 'junit:junit:4.12'
    compile "com.android.support:appcompat-v7:${SupportLibraryVersion}"


}
