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

android {
    compileSdkVersion 27

    defaultConfig {
        minSdkVersion 11
        targetSdkVersion 27
        versionCode 4
        versionName "0.9.3"

    }

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

    lintOptions {
        abortOnError false
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.0'
}

// type command in the Terminal: ./gradlew build bintrayUpload

allprojects {
    tasks.withType(Javadoc) {//兼容中文字符
        options {
            encoding "UTF-8"
            charSet 'UTF-8'
            links "http://docs.oracle.com/javase/7/docs/api"
        }
    }
}

def lib_name = "Share2"
version = "0.9.3"
group = "gdut.bsx"
def siteUrl = 'https://github.com/baishixian/Share2'
def gitUrl = 'https://github.com/baishixian/Share2.git'

install {
    repositories.mavenInstaller {
        pom {
            project {
                packaging 'aar'
                name lib_name
                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 'bsx'
                        name 'baishixian'
                        email 'baishixian@gmail.com'
                    }
                }
                scm {
                    connection gitUrl
                    developerConnection gitUrl
                    url siteUrl
                }
            }
        }
    }
}

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

task javadoc(type: Javadoc) {
    options.encoding = "UTF-8"
    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
}

javadoc {
    options {
        encoding "UTF-8"
        charSet 'UTF-8'
        author true
        version true
        links "http://docs.oracle.com/javase/7/docs/api"
        title 'A floating draggable layout for Android'   // 文档标题
    }
}

tasks.withType(Javadoc) {
    options.addStringOption('Xdoclint:none', '-quiet')
    options.addStringOption('encoding', 'UTF-8')
    options.addStringOption('charSet', 'UTF-8')
}

artifacts {
    archives javadocJar
    archives sourcesJar
}


Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def bintrayUser = properties.getProperty("bintray.user")
def bintrayApiKey = properties.getProperty("bintray.apikey")

bintray {
    user = bintrayUser
    key = bintrayApiKey
    configurations = ['archives']
    pkg {
        userOrg = "bsx"        //发布到JCenter的组织，注意新版本的bintray是需要手动创建的
        repo = "maven"              //发布到JCenter上的仓库名称，注意新版本的bintray是需要手动创建的        // 发布到Bintray上的项目名字
        name = lib_name
        websiteUrl = siteUrl
        vcsUrl = gitUrl
        licenses = ["Apache-2.0"]
        publish = true
    }
}
