group = PROJ_GROUP
version = PROJ_VERSION
project.archivesBaseName = PROJ_ARTIFACTID
def NEXUS_REPOSITORY_URL='http://maven.rongcloud.cn/repository/maven-releases/' //nexus repository url

apply plugin: 'maven'

task sourcesJar(type: Jar) {
    from 'jcenter_src'
    classifier = 'sources'
}

task javadoc(type: Javadoc) {
    failOnError false
    source = android.sourceSets.main.java.sourceFiles
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    classpath += configurations.compile
}

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

task syncJavadoc(type: Sync, dependsOn: javadoc) {
    from javadoc.destinationDir
    into rootProject.file('docs')
}

javadoc {
    options {
        encoding "UTF-8"
        charSet 'UTF-8'
        author true
        version true
        title "$PROJ_NAME $PROJ_VERSION"
        String packageListRef = "${android.sdkDirectory}/docs/reference/"
        linksOffline 'http://d.android.com/reference/', packageListRef
    }
    include()
}

artifacts {
    archives sourcesJar
    archives javadocJar
}

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: NEXUS_REPOSITORY_URL) {
                authentication(userName: BINTRAY_USER, password: BINTRAY_KEY)
            }
            pom.project {
                name PROJ_NAME
                version PROJ_VERSION
                artifactId PROJ_ARTIFACTID
                groupId PROJ_GROUP
                packaging 'aar'
//                description POM_DESCRIPTION

                licenses {
                    license {
                        name 'The Apache Software License, Version 2.0'
                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                        distribution 'repo'
                    }
                }
            }.whenConfigured {
                p ->
                    p.dependencies = p.dependencies.findAll {
                        dep ->
                            dep.scope != "test" && dep.version!="unspecified"
                    }
            }
        }
    }
}
