Skip to content
Permalink
Browse files

Implemented: Remove the Gradle wrapper jar

(OFBIZ-10145) (LEGAL-288)

As regards to LEGAL-288 [1] we remove the gradle-wrapper.jar from the source and future release packages.
Now when you run ./gradlew (or gradlew), we check before that gradle/wrapper/gradle-wrapper.jar is present
otherwise we download it before calling the wrapper.

To realize the download, we need as a prerequisite to have:
Unix-like: curl or wget
MS windows: wget

If any issue appears, it's possible to set gradle-wrapper.jar and gradle-wrapper.properties by hand on the directory gradle/wrapper/
Thanks to Jacques Leroux and Swapnil M Mane for their help

[1] https://issues.apache.org/jira/browse/LEGAL-288

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1861766 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
nmalin committed Jun 21, 2019
1 parent 20f343c commit dc85185f541b30994472078ac31f20d283d1745d
@@ -2,6 +2,7 @@ bin/
build/
applications/*/build
framework/*/build
gradle/wrapper
plugins/
runtime/git-rebase/*
runtime/SvnInfo.ftl
@@ -1,5 +1,6 @@
syntax: regexp
^(framework|applications|plugins)/[^/]+/build/.*$
^gradle/wrapper/.*$
^ofbiz\.jar$
^runtime/data/derby/.*$
^runtime/logs/.*(log|html)(|.\d+)$
@@ -72,6 +72,19 @@ the command line at the OFBiz top level directory (folder).
[[prepare-ofbiz]]
=== Prepare OFBiz:

==== Setting up the Gradle Wrapper

*Unix-like OS*: ensure that your system have `curl` or `wget` and run `./gradlew`

*MS Windows*: ensure that your system have `wget` and run `gradlew`

if some inconveniences appear please remove `OFBiz-root/gradle/wrapper` directory and run again.

*Manual setting*
* Get to https://github.com/gradle/gradle/blob/v5.0.0/gradle/wrapper, gradle-wrapper.jar and gradle-wrapper.properties
* Copy both files in your OFBiz-root\gradle\wrapper directory, that's it.

==== Clean system and load the complete OFBiz data
_________________________________________________________________________________________________________________________________________________________________________________________________________________
_Note_: Depending on your Internet connection speed it might take a long time
for this step to complete if you are using OFBiz for the first time as it needs
@@ -1,4 +1,3 @@
###############################################################################
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
@@ -15,10 +14,13 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
###############################################################################

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
if (! (Test-Path -Path ((Get-Item -Path ".\").FullName + "\gradle\"))) {
Write-Host "Location seems to be incorrect, please run the 'sh gradle/init-gradle-wrapper.ps1' script from Apache OFBiz root.";
exit
}

# This uses  PowerShell Invoke-WebRequest command (aliased as wget here)
# https is not used because we don't want users to be asked for a credential (not sure about that, maybe https is OK)
wget -outf gradle\wrapper\gradle-wrapper.jar https://svn.apache.org/repos/asf/ofbiz/tools/Buildbot/Gradle/Wrapper/trunk/gradle-wrapper.jar
wget -outf gradle\wrapper\gradle-wrapper.properties https://svn.apache.org/repos/asf/ofbiz/tools/Buildbot/Gradle/Wrapper/trunk/gradle-wrapper.properties
@@ -0,0 +1,62 @@
#!/usr/bin/env sh
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

OFBIZ_HOME="$(pwd)"
GRADLE_OFBIZ_PATH="$OFBIZ_HOME/gradle"
GRADLE_WRAPPER_OFBIZ_PATH="$GRADLE_OFBIZ_PATH/wrapper"
RELEASE="5.0.0"
#GRADLE_WRAPPER_URI="https://github.com/gradle/gradle/blob/v${RELEASE}/gradle/wrapper"
GRADLE_WRAPPER_URI="https://svn.apache.org/repos/asf/ofbiz/tools/Buildbot/Gradle/Wrapper/trunk/"
GRADLE_WRAPPER_JAR="gradle-wrapper.jar"
GRADLE_WRAPPER_PROPERTIES="gradle-wrapper.properties"
GRADLE_WRAPPER_FILES="$GRADLE_WRAPPER_JAR $GRADLE_WRAPPER_PROPERTIES"

whereIsBinary() {
whereis $1 | grep /
}

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";
exit -1;
fi

if [ ! -d "$GRADLE_WRAPPER_OFBIZ_PATH" ]; then
mkdir $GRADLE_WRAPPER_OFBIZ_PATH
fi

if [ ! -r "$GRADLE_WRAPPER_OFBIZ_PATH/$GRADLE_WRAPPER_JAR" ]; then
echo "$GRADLE_WRAPPER_OFBIZ_PATH/$GRADLE_WRAPPER_JAR not found, we download it"

if [ ! -r "$GRADLE_ZIP_RELEASE" ]; then
if [ -n "$(whereIsBinary curl)" ]; then
GET_CMD="curl -L -o";
elif [ -n "$(whereIsBinary wget)" ]; then
GET_CMD="wget -O";
else
echo "No command curl or wget found, please install one or install yourself gradle (more information see https://gradle.org/install)";
exit -1
fi
for fileToDownload in $GRADLE_WRAPPER_FILES; do
$GET_CMD $GRADLE_WRAPPER_OFBIZ_PATH/$fileToDownload $GRADLE_WRAPPER_URI/$fileToDownload?raw=true;
done
fi
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."
fi
fi
Binary file not shown.
@@ -1,4 +1,11 @@
#!/usr/bin/env sh
#####################################################################
# Apache OFBiz part
# if the gradle-wrapper.jar isn't present, call init to download it
#####################################################################
if [ ! -r ./gradle/wrapper/gradle-wrapper.jar ]; then
sh ./gradle/init-gradle-wrapper.sh
fi

#####################################################################
## Gradle start up script for UN*X
@@ -80,6 +80,13 @@ set CMD_LINE_ARGS=%*

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem check if Gradle is installed
if exist "%CLASSPATH%" goto GradleOK

md %APP_HOME%\gradle\wrapper\
Powershell.exe -executionpolicy remotesigned -File %APP_HOME%\init-gradle-wrapper.ps1

:GradleOK
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

0 comments on commit dc85185

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