plugins {
    id 'com.android.library' version '8.0.2'
    id 'org.jetbrains.kotlin.android' version '1.6.20'
    id 'maven-publish'
}

android {
    namespace 'com.digidemic.whisper'
    compileSdk 33

    defaultConfig {
        minSdk 4
        targetSdk 33

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

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }

    publishing {
        singleVariant("release") {
            withJavadocJar()
        }
    }
}

dependencies {

    implementation 'androidx.annotation:annotation:1.8.0'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'

    testImplementation 'junit:junit:4.13.2'
    testImplementation "io.mockk:mockk-android:1.13.5"
    testImplementation "io.mockk:mockk-agent:1.13.5"
}

afterEvaluate {
    android.libraryVariants.each {variant ->
        publishing.publications.create(variant.name, MavenPublication){
            from components.findByName(variant.name)

            groupId = 'com.github.whisper'
            artifactId = "whisper"
            version = '1.0.0'

            pom {
                name = 'Whisper'
                description = 'Fully customizable, non-intrusive, popup messages for Android'
                url = 'https://github.com/Digidemic/whisper'

                licenses {
                    license {
                        name = 'The Apache License, Version 2.0'
                        url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    }
                }

                developers {
                    developer {
                        id = 'Digidemic'
                        name = 'Adam Steinberg'
                        email = 'digidemic@gmail.com'
                    }
                }

                scm {
                    connection = 'scm:git://github.com/Digidemic/whisper.git'
                    developerConnection = 'scm:git://github.com/Digidemic/whisper.git'
                    url = 'git://github.com/Digidemic/whisper.git'
                }
            }
        }
    }
}