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

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
    }
}

project.archivesBaseName = 'dilatingdotsprogressbar'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        minSdkVersion 11
        targetSdkVersion 23
        versionCode 2
        versionName "1.01"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    lintOptions {
        // if true, stop the gradle build if errors are found
        abortOnError false
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
}

ext {
    bintrayRepo = 'maven'
    bintrayName = 'DilatingDotsProgressBar'

    publishedGroupId = 'com.github.justzak'
    libraryName = 'dilatingdotsprogressbar'
    artifact = 'dilatingdotsprogressbar'

    libraryDescription = 'An indeterminate progress bar with dots that expand and contract'

    siteUrl = 'https://github.com/JustZak/DilatingDotsProgressBar'
    gitUrl = 'https://github.com/JustZak/DilatingDotsProgressBar.git'

    libraryVersion = '1.0.1'

    developerId = 'ZakR'
    developerName = 'Zachary Reik'
    developerEmail = 'justzak7@gmail.com'

    licenseName = 'The MIT License'
    licenseUrl = 'https://opensource.org/licenses/MIT'
    allLicenses = ["MIT"]
}

group = publishedGroupId
version = libraryVersion

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))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}
artifacts {
    archives javadocJar
    archives sourcesJar
}

// Bintray

ext {
    binUser = 'user'
    binKey = 'key'
    binPass = 'pass'
    try {
        Properties properties = new Properties()
        properties.load(project.rootProject.file('local.properties').newDataInputStream())
        binUser = properties.getProperty("bintray.user");
        binKey = properties.getProperty("bintray.key");
        binPass = properties.getProperty("bintray.gpg.password");
    } catch (Exception e) {
    }
}

bintray {
    user = binUser
    key = binKey
    configurations = ['archives']
    pkg {
        repo = bintrayRepo
        name = bintrayName
        licenses = allLicenses
        vcsUrl = gitUrl
        publish = true
        version {
            name = libraryVersion
            desc = libraryDescription
            released  = new Date()
            gpg {
                sign = true //Determines whether to GPG sign the files. The default is false
                passphrase = binPass
                //Optional. The passphrase for GPG signing'
            }
        }
    }
}

install {
    repositories.mavenInstaller {
        pom.project {
            name bintrayName
            description libraryDescription
            url siteUrl
            inceptionYear '2016'

            packaging 'aar'
            groupId publishedGroupId
            artifactId artifact
            version libraryVersion

            licenses {
                license {
                    name licenseName
                    url licenseUrl
                    distribution 'repo'
                }
            }
            scm {
                connection gitUrl
                url siteUrl

            }
            developers {
                developer {
                    id developerId
                    name developerName
                    email developerEmail
                }
            }
        }
    }
}
