Find latest Gradle version programatically


(Jonas) #1

I’d like to run scheduled job to test my plugin against the latest Gradle version. What would be the best way to find one?

It would be great if something like ./gradlew wrapper --gradle-version=latest worked.

Any suggestions?

Thanks in advance.

(James Justinic) #2

You can create your own latestWrapper task to do this using the Gradle version web service. Splitting the configuration out into a separate task is a good idea so you don’t have every single build needing to hit the service. The distributionUrl for the Wrapper task is the downloadUrl in the JSON response.

ext.currentVersionService = ''

task configureLatestWrapper {
    doLast {
        configure(tasks.'latestWrapper') {
            distributionUrl new groovy.json.JsonSlurper().parseText(new URL(currentVersionService).text).downloadUrl

task latestWrapper(type: Wrapper) {
    dependsOn configureLatestWrapper
    group = 'wrapper'

(Jonas) #3

Didn’t know about Thanks @jjustinic!