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

android {
    compileSdkVersion versions.sdk.compile

    defaultConfig {
        minSdkVersion versions.sdk.min
        targetSdkVersion versions.sdk.target
    }
}

dependencies {
    implementation deps.kotlin.stdlib
}

def isReleaseBuild() {
    return VERSION_NAME.contains("SNAPSHOT") == false
}

signing {
    required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
    sign configurations.archives
}

uploadArchives {
    repositories {
        mavenDeployer {
            beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

            repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
                authentication(userName: mavenUser, password: mavenPassword)
            }

            snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
                authentication(userName: mavenUser, password: mavenPassword)
            }
            pom.project {

                parent {
                    groupId 'org.sonatype.oss'
                    artifactId 'oss-parent'
                    version '7'
                }


                groupId GROUP_ID
                artifactId ARTIFACT_ID
                version VERSION_NAME

                packaging 'apklib'

                name 'Foursquare native OAuth for Android'
                description 'Foursquare native authentication library makes it easier for your app\'s users to connect with Foursquare.'
                url 'https://github.com/foursquare/foursquare-android-oauth'

                scm {
                    url 'https://github.com/foursquare/foursquare-android-oauth'
                    connection 'scm:git:git://github.com/foursquare/foursquare-android-oauth.git'
                    developerConnection 'scm:git:git@github.com:foursquare/foursquare-android-oauth.git'
                    tag 'HEAD'
                }

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

                developers {
                    developer {
                        id 'foursquare'
                        name 'Foursquare'
                    }
                }

                issueManagement {
                    system 'GitHub Issues'
                    url 'https://github.com/foursquare/foursquare-android-oauth/issues'
                }
            }
        }
    }
}