Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
upload to bintray gradle task. Probably should consider making this a gradle plugin
task uploadToBintray(dependsOn: ["prepareForBintrayUpload", "publishBintrayPackages"])
task prepareForBintrayUpload << {
if (version.contains("SNAPSHOT")) {
println "bintray does not support SNAPSHOTs, skipping upload to bintray"
uploadArchives.enabled = false
publishBintrayPackages.enabled = false
return
}
if (!project.hasProperty("bintrayUsername")) {
println "bintray credentials not setup, skipping upload to bintray"
uploadArchives.enabled = false
publishBintrayPackages.enabled = false
return
}
def json = new URL("https://api.bintray.com/packages/upennlib/metridoc/metridoc-job-core").text
def slurper = new JsonSlurper()
def versions = slurper.parseText(json).versions
def versionAlreadyDeployed = versions.contains(version)
if (versionAlreadyDeployed) {
println "version $version has already been deployed to bintray, skipping upload to bintray"
uploadArchives.enabled = false
publishBintrayPackages.enabled = false
}
}
task publishBintrayPackages(dependsOn: "uploadArchives") << {
def client = new RESTClient("https://api.bintray.com/")
client.authorization = new HTTPBasicAuthorization(bintrayUsername, bintrayPassword)
def response = client.post(
path: "/content/upennlib/metridoc/metridoc-job-core/$version/publish",
accept: ContentType.JSON
) {
type ContentType.JSON
charset "utf-8"
text ""
}
println response.getContentAsString()
assert 200 == response.statusCode
}
@tbarker9
Copy link
Author

tbarker9 commented May 31, 2013

this also requires the following addition to the build classpath:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.github.groovy-wslite:groovy-wslite:0.7.2'
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment