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

install {
    repositories.mavenInstaller {
        // This generates POM.xml with proper parameters
        pom {
            project {
                packaging PACKAGING
                name ARTIFACT
                url SITE_URL
                licenses {
                    license {
                        name 'The Apache Software License, Version 2.0'
                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    }
                }
                developers {
                    developer {
                        id POM_ID
                        name POM_NAME
                        email POM_EMAIL
                    }
                }
                scm {
                    connection GIT_URL
                    developerConnection GIT_URL
                    url SITE_URL
                }
            }
        }
    }
}

//生成源文件
task sourcesJar(type: Jar) {
    from sourceSets.main.java.srcDirs
    classifier = 'sources'
}

//文档打包成jar
task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

//拷贝javadoc文件
task copyDoc(type: Copy) {
    from "${buildDir}/docs/"
    into "docs"
}

//上传到jCenter所需要的源码文件
artifacts {
    archives javadocJar
    archives sourcesJar
}

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']
    pkg {
        repo = REPO_NAME
        name = ARTIFACT                // project name in jcenter
        websiteUrl = SITE_URL
        vcsUrl = GIT_URL
        licenses = ["Apache-2.0"]
        publish = true
    }
}