import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'com.android.library'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"


    task ndkBuild(type: Exec, description: 'run ndk-build') {
        if (Os.isFamily(Os.FAMILY_WINDOWS)) {
            workingDir 'src/main/jni'
            commandLine 'ndk-build.cmd', '-j', Runtime.runtime.availableProcessors()

        } else {
            workingDir 'src/main/jni'
            commandLine "$ndkDir/ndk-build", '-j', Runtime.runtime.availableProcessors()
        }
    }

    tasks.withType(JavaCompile) {
        compileTask -> compileTask.dependsOn(ndkBuild)
    }

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        ndk
                {
                    moduleName "Scanner"
                }
    }
    sourceSets.main
            {
                jni.srcDirs = []
                jniLibs.srcDir 'src/main/libs'
            }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
}
