Last active
June 4, 2018 18:01
-
-
Save floscher/162c8559258550a4173a6c87b2454f47 to your computer and use it in GitHub Desktop.
A script for updating an existing Gradle wrapper in a given directory to another version.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
if [ $# -ne 2 ]; then | |
echo "This script needs exactly two parameters: the path where the current Gradle wrapper is and the version to which to upgrade." | |
echo "Example: ./update_gradle_wrapper.sh ./path/to/directory/to/update/ 1.2.3" | |
exit 1; | |
fi | |
distType="all" | |
path="$1" | |
version="$2" | |
cd "$path" | |
# Execute 2 times, so the wrapper task is executed by the specified Gradle version (the first time the "old" version is used). | |
# Additionally this makes sure, that the specified Gradle version is downloaded and cached. | |
for i in 0 1; do | |
./gradlew wrapper --gradle-version="$version" --distribution-type="$distType" | |
done | |
# Remove comments | |
sed -i -e '/^#.*/d' gradle/wrapper/gradle-wrapper.properties | |
# Add SHA256 sum | |
shaSum=`sha256sum ~/.gradle/wrapper/dists/gradle-$version-$distType/*/gradle-$version-$distType.zip | cut -c 1-64` | |
printf "distributionSha256Sum=$shaSum" >> gradle/wrapper/gradle-wrapper.properties |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment