apply plugin: 'com.jfrog.artifactory'

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))
}

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

artifacts {
    archives javadocJar
    archives sourcesJar
}

artifactory {
    contextUrl = 'http://oss.jfrog.org/artifactory/'
    publish {
        repository {
            // The Artifactory repository key to publish to
            repoKey = version.endsWith('SNAPSHOT') ? 'libs-snapshot-local' : 'libs-release-local'
            username = getProperties().get("bintray.user")
            password = getProperties().get("bintray.apikey")
        }
        //noinspection GroovyAssignabilityCheck
        defaults {
            publishArtifacts = true
            // Publish generated POM files to Artifactory (true by default)
            publishPom = true
        }
    }
}