Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build: Extract Gradle version from gradle-wrapper.properties #9448

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,21 @@ APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

if [ ! -e $APP_HOME/gradle/wrapper/gradle-wrapper.jar ]; then
curl -o $APP_HOME/gradle/wrapper/gradle-wrapper.jar https://raw.githubusercontent.com/gradle/gradle/v8.1.1/gradle/wrapper/gradle-wrapper.jar
GRADLE_WRAPPER_FILENAME=$(grep 'distributionUrl' gradle/wrapper/gradle-wrapper.properties | awk -F '/' '{print $NF}')
# the GRADLE_WRAPPER_FILENAME could be either "gradle-X.Y[.Z]-all.zip" or "gradle-X.Y[.Z]-bin.zip"
GRADLE_VERSION=${GRADLE_WRAPPER_FILENAME#gradle-}
GRADLE_VERSION=${GRADLE_VERSION%.zip}
GRADLE_VERSION=${GRADLE_VERSION%-bin}
GRADLE_VERSION=${GRADLE_VERSION%-all}
# when GRADLE_VERSION is X.Y, the tag is vX.Y.0
if [ $(echo $GRADLE_VERSION | tr -cd '.' | wc -c) -eq 1 ]; then
GRADLE_TAG="v$GRADLE_VERSION.0"
else
GRADLE_TAG="v$GRADLE_VERSION"
fi
GRADLE_WRAPPER_URL="https://raw.githubusercontent.com/gradle/gradle/${GRADLE_TAG}/gradle/wrapper/gradle-wrapper.jar"
echo "Downloading $GRADLE_WRAPPER_URL"
curl -o $APP_HOME/gradle/wrapper/gradle-wrapper.jar "$GRADLE_WRAPPER_URL"
fi

# Use the maximum available, or set MAX_FD != -1 to use that value.
Expand Down