Skip to content
Permalink
Browse files

Improved: update init-gradle-wrapper.sh to load gradlew script

(OFBIZ-10145)
When you run 'sh gradle/init-gradle-wrapper.sh', if the script gradlew at the OFBiz root isn't present we download it from bintray.
Improvements to comments and messages in the init-gradle-wrapper.sh script do on r1865605 by Jacopo

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1866120 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
nmalin committed Aug 30, 2019
1 parent cbc0a76 commit 6114fd496a57137de6871ae83377a46603b51305
Showing with 28 additions and 14 deletions.
  1. +5 −4 gradle/init-gradle-wrapper.ps1
  2. +23 −10 gradle/init-gradle-wrapper.sh
@@ -20,9 +20,10 @@ if ((Test-Path -Path ((Get-Item -Path ".\").FullName + "\gradle\wrapper\gradle-w
exit
}

# This uses PowerShell Invoke-WebRequest command (aliased as wget here)
# This uses PowerShell Invoke-WebRequest command (aliased as wget here)
# HTTPS is not used because it gets complicated with Powershell and .Net framework versions
# Anyway I believe this should be only used in dev environment
wget -outf gradle\wrapper\gradle-wrapper.jar http://dl.bintray.com/apacheofbiz/GradleWrapper/v5.0.0/gradle-wrapper.jar
wget -outf gradle\wrapper\gradle-wrapper.properties http://dl.bintray.com/apacheofbiz/GradleWrapper/v5.0.0/gradle-wrapper.properties

wget -outf gradle\wrapper\gradle-wrapper.jar http://dl.bintray.com/apacheofbiz/GradleWrapper/v5.0.0/gradle-wrapper.jar
wget -outf gradle\wrapper\gradle-wrapper.properties http://dl.bintray.com/apacheofbiz/GradleWrapper/v5.0.0/gradle-wrapper.properties
wget -outf gradlew.bat http://dl.bintray.com/apacheofbiz/GradleWrapper/v5.0.0/gradlew.bat

@@ -26,19 +26,21 @@ RELEASE="5.0.0"
GRADLE_WRAPPER_URI="https://dl.bintray.com/apacheofbiz/GradleWrapper/v$RELEASE/"
GRADLE_WRAPPER_URI_BACKUP="https://github.com/gradle/gradle/raw/v$RELEASE/gradle/wrapper/"

# Embded checksum shasum to control the download
# checksum to verify the downloaded file
SHASUM_GRADLE_WRAPPER_FILES="1d23286bcb9e7d3debff18c1b892b9dbb9a4ec6c gradle/wrapper/gradle-wrapper.jar
f9c2ad227ef1fe774cb0e141abfc431b05fc9fd4 gradle/wrapper/gradle-wrapper.properties"
f9c2ad227ef1fe774cb0e141abfc431b05fc9fd4 gradle/wrapper/gradle-wrapper.properties
b4a6a7e1dca81a692a775193fada937e035265f3 gradlew"

GRADLE_WRAPPER_JAR="gradle-wrapper.jar"
GRADLE_WRAPPER_PROPERTIES="gradle-wrapper.properties"
GRADLE_WRAPPER_FILES="$GRADLE_WRAPPER_JAR $GRADLE_WRAPPER_PROPERTIES"
GRADLE_WRAPPER_SCRIPT="gradlew"

whereIsBinary() {
whereis $1 | grep /
}

# Resolve the command to use for calling and realize the download
# Perform the download using curl or wget
downloadFile() {
if [ -n "$(whereIsBinary curl)" ]; then
GET_CMD="curl -L -o $GRADLE_WRAPPER_OFBIZ_PATH/$1 -s -w %{http_code} $2/$1";
@@ -55,7 +57,7 @@ downloadFile() {
return 1
}

# Call and if not succes try to use backup
# Download the file from the main URI; if the download fails then use the backup URI
resolveFile() {
downloadFile $1 $GRADLE_WRAPPER_URI;
if [ $? -eq 1 ]; then
@@ -64,15 +66,18 @@ resolveFile() {
}

echo " === Prepare operation ===";
# Control that we work the script on a good directory
# Verify that the script is executed from the right location
if [ ! -d "$GRADLE_OFBIZ_PATH" ]; then
echo "Location seems to be uncorrected, please take care to run 'sh gradle/init-gradle-wrapper.sh' at the Apache OFBiz home";
echo "Location seems to be incorrect, please run 'sh gradle/init-gradle-wrapper.sh' from the Apache OFBiz home";
exit 1;
fi
if [ ! -d "$GRADLE_WRAPPER_OFBIZ_PATH" ]; then
mkdir $GRADLE_WRAPPER_OFBIZ_PATH;
fi

# check if we have on binary to download missing wrapper
if [ -z "$(whereIsBinary curl)" ] && [ -z "$(whereIsBinary wget)" ]; then
echo "No command curl or wget found, please install one or install yourself gradle (more information see README.adoc or https://gradle.org/install)";
echo "curl or wget not found, please install one of them or install yourself gradle (for more information see README.md or https://gradle.org/install)";
exit 1
fi

@@ -85,15 +90,23 @@ if [ ! -r "$GRADLE_WRAPPER_OFBIZ_PATH/$GRADLE_WRAPPER_JAR" ]; then
done
if [ ! $? -eq 0 ]; then
rm -f $GRADLE_WRAPPER_OFBIZ_PATH/*
echo "\nDownload files $GRADLE_WRAPPER_FILES from $GRADLE_WRAPPER_URI failed.\nPlease check the log to found the reason and run the script again."
echo "\nDownload files $GRADLE_WRAPPER_FILES from $GRADLE_WRAPPER_URI failed.\nPlease check the logs, fix the problem and run the script again."
fi

if [ ! -r "$GRADLE_WRAPPER_SCRIPT" ]; then
echo " === Download script wrapper ==="
resolveFile $GRADLE_WRAPPER_SCRIPT
mv "$GRADLE_WRAPPER_OFBIZ_PATH/$GRADLE_WRAPPER_SCRIPT" .
chmod u+x $GRADLE_WRAPPER_SCRIPT
fi

echo " === Control downloaded files ==="
if [ -n "$(whereIsBinary shasum)" ]; then
echo "$SHASUM_GRADLE_WRAPPER_FILES" | shasum -c -;
exit 0;
fi

echo " Warning: shasum not found, skip the control process"
echo " Warning: shasum not found, the downloaded files could not be verified"
exit 1;
fi
echo " Nothing todo"
echo " Nothing to be done"

0 comments on commit 6114fd4

Please sign in to comment.
You can’t perform that action at this time.