apply plugin: 'com.android.library'
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        //classpath 'com.android.tools.build:gradle:3.3.2'
        //classpath 'com.android.tools.build:gradle:2.3.0'
        classpath 'com.android.tools.build:gradle:3.3.1'
    }
    //implementation {}
}

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"
    repositories {
        maven { url 'https://repo1.maven.org/maven2' }
    }
    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"

        // testIstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                //arguments "-DANDROID_STL=stl_shared"
                arguments "-DANDROID_STL=gnustl_shared"     // for ndk12b, ndk16b
                arguments "-DACL_DISABLE_HOOK_IO=YES"       // for ndk12b

                //arguments "-DANDROID_STL=c++_shared"      // for ndk20 or above
                //arguments "-DHAS_ATOMIC=YES"              // for ndk20 or above

                //arguments "-DCMAKE_VERBOSE_MAKEFILE=ON"
                arguments "-DCMAKE_BUILD_TYPE=RELEASE"
                arguments "-DCMAKE_CXX_FLAGS_RELEASE=-O3"
                arguments "-DCMAKE_C_FLAGS_RELEASE=-O3"
                arguments "-DACL_CLIENT_ONLY=YES"
                arguments "-DHAS_MBEDTLS=YES"
                arguments "-DACL_BUILD_SHARED=YES"
                //cppFlags "-fexceptions"

                //abiFilters 'armeabi', 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'
                abiFilters 'armeabi', 'arm64-v8a', 'armeabi-v7a', 'x86'    // for ndk12b, ndk16b
                //abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86'             // for ndk20 or above
            }
            cmake {
                //arguments '-DANDROID_PLATFORM=android-14','-DANDROID_TOOLCHAIN=clang'
                targets 'acl_static', 'protocol_static', 'acl_cpp_static', 'fiber_static', 'fiber_cpp_static'  // for ndk12b, ndk16b
                //targets 'acl_static', 'protocol_static', 'acl_cpp_static', 'fiber_static', 'fiber_cpp_static', 'acl', 'protocol', 'acl_cpp', 'fiber', 'fiber_cpp'  // for ndk20 or above
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            jniDebuggable true
            debuggable true
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path '../../CMakeLists.txt'
            version "3.10.2"
        }
    }
    packagingOptions {
        exclude 'lib/arm64-v8a/libgnustl_shared.so'
        exclude 'lib/armeabi-v7a/libgnustl_shared.so'
        exclude 'lib/armeabi/libgnustl_shared.so'
        exclude 'lib/x86/libgnustl_shared.so'
        exclude 'lib/arm64-v8a/libc++_shared.so'
        exclude 'lib/armeabi-v7a/libc++_shared.so'
        exclude 'lib/armeabi/libc++_shared.so'
        exclude 'lib/x86/libc++_shared.so'
    }
    productFlavors {
    }
}

dependencies {
    //compile fileTree(include: ['*.jar'], dir: 'libs')
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    //androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    //compile 'com.android.support:appcompat-v7:25.3.1'
    //compile 'com.android.support.constraint:constraint-layout:1.0.2'
    //testCompile 'junit:junit:4.12'
    //compile files('libs/junit-4.12.jar')
    //implementation files('libs/junit-4.12.jar')
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}
