import groovy.json.*

buildscript {
    ext.kotlin_version = rootProject.properties.get('kotlinVersion', '1.3.61')

    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

ext.readJson = { File file ->
    def json = new JsonSlurper().parse(file)
    return json
}

ext.pluginVersion = readJson(project.file("../package.json")).version
ext.payjpSdkVersion = readJson(project.file("../sdkconfig.json")).android

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
    namespace 'jp.pay.reactnative'
    compileSdkVersion rootProject.properties.get('compileSdkVersion', 29)

    defaultConfig {
        minSdkVersion rootProject.properties.get('minSdkVersion', 16)
        targetSdkVersion rootProject.properties.get('targetSdkVersion', 29)
        buildConfigField "String", "VERSION_NAME", "\"$pluginVersion\""
    }
    lintOptions {
        warning 'InvalidPackage'
    }
}

repositories {
    google()
    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url("$rootDir/../node_modules/react-native/android")
    }
    mavenCentral()
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    //noinspection GradleDynamicVersion
    implementation 'com.facebook.react:react-native:+'
    implementation "jp.pay:payjp-android:$payjpSdkVersion"
}
