#!/usr/bin/env bash

repo='kotlin-dsl-snapshots-local'

# .children[-2] selects the one before the last which is the all distro
latestSnapshotPath=`
    http get https://repo.gradle.org/gradle/api/storage/$repo/ \
        | jq -r '[ .children[] | select(.uri | startswith("/gradle-kotlin-dsl-4.9-")) ][-2].uri'`

find . -name gradle-wrapper.properties \
    | xargs perl -p -i -e "s|^(distributionUrl=.*$repo).*|\$1$latestSnapshotPath|"

find . -name gradle-wrapper.properties \
    | xargs git commit -m"Update wrappers to latest snapshot distro"

#!/usr/bin/env bash

repo='kotlin-dsl-snapshots-local'

# .children[-2] selects the one before the last which is the all distro
latestSnapshotPath=`
    http get https://repo.gradle.org/gradle/api/storage/$repo/ \
        | jq -r '[ .children[] | select(.uri | startswith("/gradle-kotlin-dsl-")) ][-2].uri'`

find . -name gradle-wrapper.properties \
    | xargs perl -p -i -e "s|^(distributionUrl=.*$repo).*|\$1$latestSnapshotPath|"

find . -name gradle-wrapper.properties \
    | xargs git commit -m"Update wrappers to latest snapshot distro"

Revert "Pin snapshot distro to 4.9"
Revert "Pin snapshot distro to 4.9"

This reverts commit a833016273624d104841016a29585fa8fff84e73.
