plugins {
    id 'com.android.library'
    id 'kotlin-android'
    id 'kotlin-kapt'
    id 'maven-publish'
    id 'signing'
}
android {
    compileSdk 31

    defaultConfig {
        minSdk 17
        targetSdk 31
    }

    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'
    }

    buildFeatures {
        viewBinding true
    }
}

dependencies {
    compileOnly "androidx.core:core-ktx:1.7.0"
    compileOnly "androidx.appcompat:appcompat:1.4.1"
    api "io.github.vincent-series:common:1.0.7"
    kapt "io.github.vincent-series:annotation-compiler:1.0.3"
}
afterEvaluate {
    publishing {
        def stagingVersion = "4.0.5"
        def snapshotsVersion = "4.0.1-1.0.0-SNAPSHOT"
        def uploadVersion = stagingVersion
        publications {
            maven(MavenPublication) {
                from components.release
                groupId = 'io.github.vincent-series'
                artifactId = 'smart-dialog'
                version = uploadVersion

                pom {
                    name = 'smart-dialog'
                    description = 'robust dialog lib developed by zhiqiang.zhu.'
                    url = 'https://github.com/vincent-series/smart-show'

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

                    developers {
                        developer {
                            id = 'zhiqiang.zhu'
                            name = 'zhiqiang.zhu'
                            email = 'coder_zzq@aliyun.com'
                        }
                    }
                    scm {
                        connection = 'scm:git:https://github.com/vincent-series/smart-show.git'
                        developerConnection = 'scm:git:https://github.com/vincent-series/smart-show.git'
                        url = 'https://github.com/vincent-series/smart-show'
                    }
                }

                artifact generateSourcesJar
            }
        }


        signing {
            sign publishing.publications.maven
        }
    }
}

task generateSourcesJar(type: Jar) {
    group = 'jar'
    archiveClassifier.set("sources")
    from("src/main/java")
}