Last active
September 9, 2022 20:09
-
-
Save parzonka/9371885 to your computer and use it in GitHub Desktop.
Install gradle on redhat/centos linux
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
# installs to /opt/gradle | |
# existing versions are not overwritten/deleted | |
# seamless upgrades/downgrades | |
# $GRADLE_HOME points to latest *installed* (not released) | |
gradle_version=2.9 | |
wget -N https://services.gradle.org/distributions/gradle-${gradle_version}-all.zip | |
sudo unzip -foq gradle-${gradle_version}-all.zip -d /opt/gradle | |
sudo ln -sfn gradle-${gradle_version} /opt/gradle/latest | |
sudo printf "export GRADLE_HOME=/opt/gradle/latest\nexport PATH=\$PATH:\$GRADLE_HOME/bin" > /etc/profile.d/gradle.sh | |
. /etc/profile.d/gradle.sh | |
# check installation | |
gradle -v |
Fixed gradle_version determination in @fluffybastard version. Checked on CentOS 7.1
#!/bin/bash
cd /root
gradle_package=`curl -s http://services.gradle.org/distributions --list-only | sed -n 's/.*\(gradle-.*.all.zip\).*/\1/p' | egrep -v "milestone|rc" | head -1`
gradle_version=`echo ${gradle_package} | cut -d "-" -f 1,2`
mkdir /opt/gradle
curl -L -Of http://services.gradle.org/distributions/${gradle_package}
unzip -oq ./${gradle_package} -d /opt/gradle
ln -sfnv ${gradle_version} /opt/gradle/latest
printf "export GRADLE_HOME=/opt/gradle/latest\nexport PATH=\$PATH:\$GRADLE_HOME/bin" > /etc/profile.d/gradle.sh
. /etc/profile.d/gradle.sh
hash -r ; sync
# check installation
gradle -v
It became easy :
https://gradle.org/gradle-download/
Snippet:
Install with SDKMAN!
Get SDKMAN!
$ curl -s https://get.sdkman.io | bash
Open a new terminal and install Gradle
$ sdk install gradle 3.0
sudo printf "export GRADLE_HOME=/opt/gradle/latest\nexport PATH=$PATH:$GRADLE_HOME/bin" > /etc/profile.d/gradle.sh
I get
-bash: /etc/profile.d/gradle.sh: Permission denied
But im the root user and im using the sudo command
Try this:
printf "export GRADLE_HOME=/opt/gradle/latest\nexport PATH=\$PATH:\$GRADLE_HOME/bin" | sudo tee /etc/profile.d/gradle.sh
Thanks! It was very succinct info.
Instead of gradle -v I had to do /opt/gradle/bin/gradle -v
CentOS Linux release 7.5.1804 (Core)
# !/bin/bash
# installs to /opt/gradle
# existing versions are not overwritten/deleted
# seamless upgrades/downgrades
# $GRADLE_HOME points to latest *installed* (not released)
gradle_version=4.8.1
if [ ! -d "/opt/gradle" ];then
mkdir /opt/gradle
fi
if [ ! -f "./gradle-${gradle_version}-all.zip" ];then
wget -N http://services.gradle.org/distributions/gradle-${gradle_version}-all.zip
fi
unzip -oq ./gradle-${gradle_version}-all.zip -d /opt/gradle
ln -sfnv gradle-${gradle_version} /opt/gradle/latest
printf "export GRADLE_HOME=/opt/gradle/latest\nexport PATH=\$PATH:\$GRADLE_HOME/bin" > /etc/profile.d/gradle.sh
. /etc/profile.d/gradle.sh
hash -r ; sync
# check installation
gradle -v
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you don't have wget installed and want to stick with curl for the download as well, replace the wget line with:
curl -L -Of http://services.gradle.org/distributions/${gradle_package}