apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

def siteUrl = 'https://github.com/appformation/smash'
def gitUrl = 'https://github.com/appformation/smash.git'

group = "pl.appformation"
version = '0.3.0'

install
{
    repositories.mavenInstaller
    {
        pom.project
        {
            packaging 'aar'

            name 'Smash'
            description 'Smash is Volley inspired networking library that\'s using OkHttp in its core'
            version '0.3.0'

            url siteUrl

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

            developers { developer
            {
                id 'appformation'
                name 'Appformation'
                email 'lukasz@appformation.pl'
            } }

            scm
            {
                connection gitUrl
                developerConnection gitUrl
                url siteUrl
            }
        }
    }
}

task sourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

task javadoc(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    classpath += configurations.compile
}

task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}
artifacts {
    archives javadocJar
    archives sourcesJar
}

if (project.rootProject.file("local.properties").exists())
{
    Properties properties = new Properties()
    properties.load(project.rootProject.file('local.properties').newDataInputStream())

    bintray
    {
        user = properties.getProperty("bintray.user")
        key = properties.getProperty("bintray.apikey")

        configurations = ['archives']
        dryRun = false

        pkg
        {
            repo = "maven"
            name = "Smash"
            websiteUrl = siteUrl
            vcsUrl = gitUrl
            licenses = ["Apache-2.0"]
            publish = true
        }
        pkg.version
        {
            name = "0.3.0"
            vcsTag = '0.3.0'
        }
        pkg.version.gpg
        {
            sign = true
            passphrase = properties.getProperty("bintray.gpg.password")
        }
    }
}
