plugins {
    id 'com.android.library'
    id 'kotlin-android'
    id 'maven-publish'
}

android {
    compileSdk 31
    ndkVersion '21.1.6352462'

    defaultConfig {
        minSdk 21
        targetSdk 31

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"

        externalNativeBuild {
            cmake {
                cppFlags "-std=c++11 -frtti -fexceptions -Wno-format"
                arguments '-DANDROID_PLATFORM=android-23', '-DANDROID_STL=c++_shared' ,"-DANDROID_ARM_NEON=TRUE"
            }
        }
        ndk {
            // abiFilters "arm64-v8a", "armeabi-v7a"
            abiFilters   "arm64-v8a", "armeabi-v7a"
            ldLibs "jnigraphics"
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    kotlinOptions {
        jvmTarget = '11'
    }
    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"
            version "3.10.2"
        }
    }
}

afterEvaluate {
    publishing {
        publications {
            release(MavenPublication){
                from components.release
                groupId = 'com.equationl.paddleocr4android'
                artifactId = 'paddleocr4android'
                version = 'V1.2.0'
            }
        }
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}