Skip to content

Instantly share code, notes, and snippets.

@tbarker9
Created May 31, 2013 10:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbarker9/5684208 to your computer and use it in GitHub Desktop.
Save tbarker9/5684208 to your computer and use it in GitHub Desktop.
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

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