plugins {
    id("com.android.library")
    id("kotlin-android")
}

ext {
    PUBLISH_GROUP_ID = '{{ sdk.namespace | caseDot }}'
    PUBLISH_ARTIFACT_ID = '{{ sdk.gitRepoName | caseDash }}'
    PUBLISH_VERSION = System.getenv('SDK_VERSION')
    POM_URL = 'https://github.com/{{ sdk.gitUserName }}/{{ sdk.gitRepoName }}'
    POM_SCM_URL = 'https://github.com/{{ sdk.gitUserName }}/{{ sdk.gitRepoName }}'
    POM_ISSUE_URL = 'https://github.com/{{ sdk.gitUserName }}/{{ sdk.gitRepoName }}/issues'
    POM_DESCRIPTION = '{{ sdk.description }}'
    POM_LICENSE_URL = 'https://opensource.org/licenses/GPL-3.0'
    POM_LICENSE_NAME = "GPL-3.0"
    POM_DEVELOPER_ID = '{{ sdk.gitUserName }}'
    POM_DEVELOPER_NAME = '{{ spec.contactName }}'
    POM_DEVELOPER_EMAIL = '{{ spec.contactEmail }}'
    GITHUB_SCM_CONNECTION = 'scm:git:git://github.com/{{ sdk.gitUserName }}/{{ sdk.gitRepoName }}.git'
}

version PUBLISH_VERSION

android {
    namespace PUBLISH_GROUP_ID

    compileSdkVersion(34)

    buildFeatures {
        buildConfig true
    }

    defaultConfig {
        minSdkVersion(21)
        targetSdkVersion(34)
        versionCode = 1
        versionName = "1.0"
        buildConfigField "String", "SDK_VERSION", "\"${PUBLISH_VERSION}\""
        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles("consumer-rules.pro")
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

dependencies {
    implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version")
    api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1")
    api("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1")

    implementation("com.squareup.okhttp3:okhttp:4.12.0")
    implementation("com.google.code.gson:gson:2.10.1")

    implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
    implementation("androidx.lifecycle:lifecycle-common-java8:2.7.0")
    implementation("androidx.appcompat:appcompat:1.6.1")
    implementation("androidx.fragment:fragment-ktx:1.6.2")
    implementation("androidx.activity:activity-ktx:1.8.2")
    implementation("androidx.browser:browser:1.7.0")
    implementation("androidx.core:core-ktx:1.12.0")

    testImplementation("junit:junit:4.13.2")
    testImplementation("androidx.test.ext:junit-ktx:1.1.5")
    testImplementation("androidx.test:core-ktx:1.5.0")
    testImplementation("org.robolectric:robolectric:4.11.1")
    testApi("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.1")
}

apply from: "${rootProject.projectDir}/scripts/publish-module.gradle"
