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

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

Properties secret = new Properties()
if (!project.hasProperty('type')) {
    secret.load(project.rootProject.file('secret.properties').newDataInputStream())
}

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName VERSION_NAME
    }

    sourceSets {
        main.jniLibs.srcDirs = ['libs']
    }

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

}

// Configure gradle-bintray-plugin (for publishing releases)
bintray {
    user = secret.getProperty('bintray.user')
    key = secret.getProperty('bintray.key')
    configurations = ['archives']
    publish = true
    pkg {
        repo = "sdks"
        name = "socialsdk"
        userOrg = "elbbbirdstudio"
        desc = 'A social sdk for WeChat, Weibo and QQ.'
        websiteUrl = 'https://github.com/ElbbbirdStudio/ESSocialSDK'
        issueTrackerUrl = 'https://github.com/ElbbbirdStudio/ESSocialSDK/issues'
        vcsUrl = 'https://github.com/ElbbbirdStudio/ESSocialSDK.git'
        licenses = ['Apache-2.0']
        labels = ['socialsdk', 'elbbbird']
        publicDownloadNumbers = true
    }
}

// Configure android-maven-gradle-plugin
group = GROUP
version = VERSION_NAME
install {
    repositories.mavenInstaller.pom.project {
        packaging POM_PACKAGING
        name POM_NAME
        url POM_URL
        description POM_DESCRIPTION

        licenses {
            license {
                name POM_LICENSE_NAME
                url POM_LICENSE_URL
                distribution POM_LICENSE_DIST
            }
        }

        scm {
            url POM_SCM_URL
            connection POM_SCM_CONNECTION
            developerConnection POM_SCM_DEV_CONNECTION
        }

        developers {
            developer {
                id 'hailong0707'
                name 'Hailong Zhang'
                email 'hailong0707@gmail.com'
            }
        }
    }
}

//Build sources jar
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))
    options.encoding = "UTF-8"
}

//Build javadoc jar
task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives sourcesJar
    archives javadocJar
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile files('libs/weiboSDKCore_3.1.2.jar')
    compile files('libs/libammsdk.jar')
    compile files('libs/open_sdk_r5509_lite.jar')
    compile files('libs/otto-1.3.8.jar')
}
