-
-
Save parzonka/9371885 to your computer and use it in GitHub Desktop.
# 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 |
Thanks for share it, is works perfectly for gradle 1.5, you should change the download URL for http://downloads.gradle.org/distributions
I had some troubles when was trying run yours script so i did small changes to fix this.
#!/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=1.11
mkdir /opt/gradle
wget -N http://services.gradle.org/distributions/gradle-${gradle_version}-all.zip
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
rehash ; sync
# check installation
gradle -v
Cheers. I had to manually create /opt/gradle and run the commands by hand, but thanks.
Nice. Thanks for the post.
Thanks for the post.
With a few changes works great on RHEL 7.1. Thank you!
#!/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=2.3
mkdir /opt/gradle
wget -N http://services.gradle.org/distributions/gradle-${gradle_version}-all.zip
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
Download address has changed...
#!/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=2.3 mkdir /opt/gradle wget -N http://downloads.gradle.org/distributions/gradle-${gradle_version}-all.zip 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
With Homebrew: brew install gradle
Updated url and version to v2.9
thanks!
Thanks for this. Small improvement though:
sudo printf "export GRADLE_HOME=/opt/gradle/latest\nexport PATH=\$PATH:\$GRADLE_HOME/bin" > /etc/profile.d/gradle.sh
should be
printf "export GRADLE_HOME=/opt/gradle/latest\nexport PATH=\$PATH:\$GRADLE_HOME/bin" | sudo tee /etc/profile.d/gradle.sh >/dev/null
Building on what others wrote, here is a small script that works on Centos 7 (always returns the latest version of gradle from the URL)
#!/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=`ls ${gradle_package} | cut -d "-" -f 1,2`
mkdir /opt/gradle
wget -N 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
Above script works on Fedora 23 👍
Yes, it works! Thx :)
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}
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
Nice. Thanks for the post.