# Find latest Gradle version programatically

**URL:** <https://discuss.gradle.org/t/find-latest-gradle-version-programatically/24262>\
**Category:** Help/Discuss\
**Tags:** plugins\
**Created:** [September 30, 2017, 9:34am UTC](https://discuss.gradle.org/t/find-latest-gradle-version-programatically/24262 "2017-09-30T09:34:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonas-l](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jonas-l/32/5412_2.png) [@jonas-l](https://discuss.gradle.org/u/jonas-l)\
**Post date:** [September 30, 2017, 9:34am UTC](https://discuss.gradle.org/t/find-latest-gradle-version-programatically/24262/1 "2017-09-30T09:34:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jjustinic](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jjustinic/32/9005_2.png) [@jjustinic](https://discuss.gradle.org/u/jjustinic)\
**Post date:** [September 30, 2017, 2:45pm UTC](https://discuss.gradle.org/t/find-latest-gradle-version-programatically/24262/2 "2017-09-30T14:45:04Z")

</div>

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.

```groovy
ext.currentVersionService = 'https://services.gradle.org/versions/current'

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

```

---

<div class="post-metadata">

**Author:** ![jonas-l](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jonas-l/32/5412_2.png) [@jonas-l](https://discuss.gradle.org/u/jonas-l)\
**Post date:** [September 30, 2017, 5:34pm UTC](https://discuss.gradle.org/t/find-latest-gradle-version-programatically/24262/3 "2017-09-30T17:34:59Z")

</div>

Didn’t know about `https://services.gradle.org/versions/current`. Thanks @jjustinic!
