svn commit: r1866120 - in /ofbiz/ofbiz-framework/trunk/gradle: init-gradle-wrapper.ps1 init-gradle-wrapper.sh

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1866120 - in /ofbiz/ofbiz-framework/trunk/gradle: init-gradle-wrapper.ps1 init-gradle-wrapper.sh

nmalin
Author: nmalin
Date: Fri Aug 30 07:14:34 2019
New Revision: 1866120

URL: http://svn.apache.org/viewvc?rev=1866120&view=rev
Log:
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

Modified:
    ofbiz/ofbiz-framework/trunk/gradle/init-gradle-wrapper.ps1
    ofbiz/ofbiz-framework/trunk/gradle/init-gradle-wrapper.sh

Modified: ofbiz/ofbiz-framework/trunk/gradle/init-gradle-wrapper.ps1
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/gradle/init-gradle-wrapper.ps1?rev=1866120&r1=1866119&r2=1866120&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/gradle/init-gradle-wrapper.ps1 (original)
+++ ofbiz/ofbiz-framework/trunk/gradle/init-gradle-wrapper.ps1 Fri Aug 30 07:14:34 2019
@@ -20,9 +20,10 @@ if ((Test-Path -Path ((Get-Item -Path ".
     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
+

Modified: ofbiz/ofbiz-framework/trunk/gradle/init-gradle-wrapper.sh
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/gradle/init-gradle-wrapper.sh?rev=1866120&r1=1866119&r2=1866120&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/gradle/init-gradle-wrapper.sh (original)
+++ ofbiz/ofbiz-framework/trunk/gradle/init-gradle-wrapper.sh Fri Aug 30 07:14:34 2019
@@ -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/$G
     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"