apply plugin: "com.android.library"
apply plugin: "com.facebook.react"

def DEFAULT_COMPILE_SDK_VERSION = 26
def DEFAULT_BUILD_TOOLS_VERSION = "26.0.3"
def DEFAULT_TARGET_SDK_VERSION = 26
def DEFAULT_MIN_SDK_VERSION = 16

react {
    jsRootDir = file("..")
    libraryName = "RNCodePushSpec"
    codegenJavaPackageName = "com.microsoft.codepush.react"
}

android {
    namespace "com.microsoft.codepush.react"

    compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
    buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION

    defaultConfig {
        minSdkVersion rootProject.hasProperty('minSdkVersion') ? rootProject.minSdkVersion : DEFAULT_MIN_SDK_VERSION
        targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
        versionCode 1
        versionName "1.0"
    }

    lintOptions {
        abortOnError false
    }

    defaultConfig {
        consumerProguardFiles 'proguard-rules.pro'
    }

    // Builds the binary patch applier. Its sources are the shared ones at the root of the
    // repository, which the CMake file points at; nothing is compiled twice.
    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"
        }
    }

    testOptions {
        // The unit tests exercise plain logic, so the android framework classes they touch
        // in passing (logging above all) are allowed to do nothing instead of throwing.
        unitTests.returnDefaultValues = true
    }
}

dependencies {
    implementation "com.facebook.react:react-native:+"

    testImplementation "junit:junit:4.13.2"
    // org.json ships as stubs in the android framework jar, and the unit tests parse real
    // manifests, so they need an implementation that actually parses.
    testImplementation "org.json:json:20231013"
}
