Created
July 1, 2023 15:07
-
-
Save ed-george/3751d09ccdfd33cfe48d8987d9f68510 to your computer and use it in GitHub Desktop.
Verify your Gradle Wrapper's integrity
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
#!/bin/zsh | |
# This script will verify your gradle-wrapper.jar | |
# file's integrity for your project's Gradle version | |
# For more info, see: | |
# https://docs.gradle.org/current/userguide/gradle_wrapper.html#manually_verifying_the_gradle_wrapper_jar | |
# | |
# Usage: ./gradle-wrapper-verify.sh | |
# Use within $PROJ_ROOT/gradle/wrapper folder | |
file="./gradle-wrapper.properties" | |
function property { | |
grep "${1}" ${file} | cut -d '=' -f2 | |
} | |
# Fetch Gradle Version (via distributionUrl property) | |
DIST_URL=$(property 'distributionUrl') | |
GRADLE_VERSION=$(echo $DIST_URL | cut -d '-' -f2 | cut -d '-' -f1) | |
# Download gradle-wrapper.jar.sha256 for Gradle version | |
URL="https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-wrapper.jar.sha256" | |
echo "Downloading Gradle $GRADLE_VERSION wrapper sha256" | |
curl -s --location --output gradle-wrapper.jar.sha256 $URL | |
# Verify gradle-wrapper.jar file | |
echo "Verifying Gradle $GRADLE_VERSION wrapper" | |
echo "$(cat gradle-wrapper.jar.sha256) gradle-wrapper.jar" | shasum --check || echo "Check failed" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment