def VERSION = '0.1.5'
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:0.5'
    }
}
apply plugin: 'com.android.library'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'

android {
    compileSdkVersion 19
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "com.emmano.blurstickyheaderlistviewlib"
        minSdkVersion 11
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
        renderscriptTargetApi 19
        renderscriptSupportMode true
    }

    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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

task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
    from androidJavadocs.destinationDir
}

task androidSourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
}

publishing {
    publications {
        dist(MavenPublication) {
            groupId 'me.emmano'
            version VERSION
            artifactId 'blurstickyheaderlistview'
            artifact "build/outputs/aar/blurstickyheaderlistviewlib.aar"
            artifact androidJavadocsJar {
                classifier 'source'
            }
            artifact androidSourcesJar {
                classifier 'javadoc'
            }
            pom.withXml {
                def root = asNode()
                def dependencies = root.appendNode('dependencies')
                configurations.compile.allDependencies.each {
                    if (it['group'] != null) {
                        def dependency = dependencies.appendNode('dependency')
                        dependency?.appendNode('groupId', it['group'])
                        dependency?.appendNode('artifactId', it['name'])
                        dependency?.appendNode('version', it['version'])
                    }
                }
            }
        }
    }
}

bintray {
    user = bintrayUser
    key = bintrayApiKey
    publications = ['dist']

    dryRun = false
    publish = false
    pkg {
        repo = 'emmano'
        name = 'me.emmano.blurheaderstickylistview'
        desc = 'ListView that allows to easily display an image form the internet on its header. It blurs the image and applies a parallax effect to the header. It also offers sticky title functionality.'
        websiteUrl = 'https://github.com/emmano/BlurStickyHeaderListView/'
        issueTrackerUrl = 'https://github.com/emmano/BlurStickyHeaderListView/issues'
        vcsUrl = 'https://github.com/emmano/BlurStickyHeaderListView.git'
        licenses = ['MIT']
        labels = ['Android', 'ListView']
        publicDownloadNumbers = true

        version {
            name = VERSION //Bintray logical VERSION name
            desc = 'Added Google+ effect to ActionBar'
            vcsTag = VERSION
        }
    }
}

dependencies {
    compile 'com.squareup.picasso:picasso:2.3.+'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:20.0.0'
}
