1. 자바 버전 확인

$ java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-8u222-b10-1~deb9u1-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)

2. Gradle 설치

2-1. 다운로드

링크 : https://gradle.org/releases/

2-2. 패키지 설치

$ sudo apt-get install gradle
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  ant ant-optional antlr bnd glassfish-jmac-api groovy ivy java-wrappers javascript-common junit junit4 libantlr-java libaopalliance-java libapache-pom-java libasm-java libatinject-jsr330-api-java
  libbcel-java libbcpg-java libbcprov-java libbindex-java libbsf-java libbsh-java libcdi-api-java libcglib-java libclassworlds-java libcommons-cli-java libcommons-codec-java libcommons-collections3-java
  libcommons-dbcp-java libcommons-httpclient-java libcommons-io-java libcommons-lang-java libcommons-lang3-java libcommons-logging-java libcommons-net-java libcommons-parent-java libcommons-pool-java
  libdom4j-java libdoxia-core-java libeasymock-java libecj-java libeclipse-aether-java libfelix-osgi-obr-java libfindbugs-java libgeronimo-interceptor-3.0-spec-java libgoogle-gson-java libgpars-groovy-java
  libgradle-core-java libgradle-plugins-java libguava-java libguice-java libhamcrest-java libhawtjni-runtime-java libhttpclient-java libhttpcore-java libisorelax-java libjansi-java libjansi-native-java
  libjarjar-java libjatl-java libjaxen-java libjaxp1.3-java libjcifs-java libjcip-annotations-java libjcommander-java libjcsp-java libjdom1-java libjetty9-extra-java libjetty9-java libjformatstring-java
  libjline2-java libjna-java libjna-jni libjs-jquery libjsch-java libjsoup-java libjsr166y-java libjsr305-java libjzlib-java libkryo-java libkxml2-java liblog4j1.2-java liblogback-java libmail-java
  libmaven-parent-java libmaven2-core-java libmaven3-core-java libminlog-java libmsv-java libmultiverse-core-java libnative-platform-java libnative-platform-jni libnekohtml-java libnetty-3.9-java
  libobjenesis-java libosgi-annotation-java libosgi-compendium-java libosgi-core-java libplexus-ant-factory-java libplexus-archiver-java libplexus-bsh-factory-java libplexus-cipher-java
  libplexus-classworlds-java libplexus-classworlds2-java libplexus-cli-java libplexus-component-annotations-java libplexus-component-metadata-java libplexus-container-default-java
  libplexus-container-default1.5-java libplexus-containers-java libplexus-containers1.5-java libplexus-interactivity-api-java libplexus-interpolation-java libplexus-io-java libplexus-sec-dispatcher-java
  libplexus-utils-java libplexus-utils2-java libpolyglot-maven-java libqdox-java libqdox2-java libreflectasm-java librelaxng-datatype-java librhino-java libservlet3.1-java libsimple-http-java
  libsisu-inject-java libsisu-plexus-java libslf4j-java libspring-beans-java libspring-core-java libtaglibs-standard-impl-java libtaglibs-standard-spec-java libtomcat8-java libwagon-java libwagon2-java
  libxalan2-java libxbean-java libxerces2-java libxml-commons-external-java libxml-commons-resolver1.1-java libxom-java libxpp2-java libxpp3-java libxstream-java libyaml-snake-java testng unzip
Suggested packages:
  ant-doc ant-gcj ant-optional-gcj javacc jython libjdepend-java liboro-java libregexp-java eclipse-jdt eclipse-rcp default-jre gradle-doc groovy-doc libjsch-agent-proxy-java ivy-doc junit-doc
  libaopalliance-java-doc libatinject-jsr330-api-java-doc libbcel-java-doc libbcpg-java-doc libbcprov-java-doc bsh rhino libclassworlds-java-doc libcommons-collections3-java-doc libcommons-dbcp-java-doc
  libgeronimo-jta-1.1-spec-java libcommons-httpclient-java-doc libcommons-io-java-doc libcommons-lang-java-doc libcommons-lang3-java-doc libavalon-framework-java libcommons-logging-java-doc
  libexcalibur-logkit-java libcommons-net-java-doc libdom4j-java-doc libeasymock-java-doc ecj libecj-java-gcj libfelix-osgi-obr-java-doc libgoogle-gson-java-doc libgpars-groovy-java-doc libjaxp1.3-java-gcj
  libjcifs-java-doc libjcommander-java-doc libjcsp-java-doc libjdom1-java-doc jetty9 libjna-java-doc libjsoup-java-doc libjsr305-java-doc liblog4j1.2-java-doc libgeronimo-jms-1.1-spec-java libjanino-java
  libmail-java-doc libnative-platform-java-doc libnekohtml-java-doc libbcpkix-java libjboss-logging-java libnetty-tcnative-java libprotobuf-java libobjenesis-java-doc libosgi-annotation-java-doc
  libosgi-compendium-java-doc libosgi-core-java-doc libplexus-cipher-java-doc libplexus-classworlds-java-doc libplexus-classworlds2-java-doc libplexus-cli-java-doc libplexus-container-default-java-doc
  libplexus-interactivity-api-java-doc libplexus-interpolation-java-doc libplexus-sec-dispatcher-java-doc libplexus-utils-java-doc libplexus-utils2-java-doc libpolyglot-maven-java-doc libqdox-java-doc
  libqdox2-java-doc libsimple-http-java-doc libaspectj-java tomcat8 libwagon-java-doc libxalan2-java-doc libxsltc-java libequinox-osgi-java libspring-context-java libspring-web-java libxerces2-java-doc
  libxerces2-java-gcj libxml-commons-resolver1.1-java-doc libxom-java-doc libcglib-nodep-java libjdom2-java libjettison-java libjoda-time-java libwoodstox-java zip
The following NEW packages will be installed:
  ant ant-optional antlr bnd glassfish-jmac-api gradle groovy ivy java-wrappers javascript-common junit junit4 libantlr-java libaopalliance-java libapache-pom-java libasm-java libatinject-jsr330-api-java
  libbcel-java libbcpg-java libbcprov-java libbindex-java libbsf-java libbsh-java libcdi-api-java libcglib-java libclassworlds-java libcommons-cli-java libcommons-codec-java libcommons-collections3-java
  libcommons-dbcp-java libcommons-httpclient-java libcommons-io-java libcommons-lang-java libcommons-lang3-java libcommons-logging-java libcommons-net-java libcommons-parent-java libcommons-pool-java
  libdom4j-java libdoxia-core-java libeasymock-java libecj-java libeclipse-aether-java libfelix-osgi-obr-java libfindbugs-java libgeronimo-interceptor-3.0-spec-java libgoogle-gson-java libgpars-groovy-java
  libgradle-core-java libgradle-plugins-java libguava-java libguice-java libhamcrest-java libhawtjni-runtime-java libhttpclient-java libhttpcore-java libisorelax-java libjansi-java libjansi-native-java
  libjarjar-java libjatl-java libjaxen-java libjaxp1.3-java libjcifs-java libjcip-annotations-java libjcommander-java libjcsp-java libjdom1-java libjetty9-extra-java libjetty9-java libjformatstring-java
  libjline2-java libjna-java libjna-jni libjs-jquery libjsch-java libjsoup-java libjsr166y-java libjsr305-java libjzlib-java libkryo-java libkxml2-java liblog4j1.2-java liblogback-java libmail-java
  libmaven-parent-java libmaven2-core-java libmaven3-core-java libminlog-java libmsv-java libmultiverse-core-java libnative-platform-java libnative-platform-jni libnekohtml-java libnetty-3.9-java
  libobjenesis-java libosgi-annotation-java libosgi-compendium-java libosgi-core-java libplexus-ant-factory-java libplexus-archiver-java libplexus-bsh-factory-java libplexus-cipher-java
  libplexus-classworlds-java libplexus-classworlds2-java libplexus-cli-java libplexus-component-annotations-java libplexus-component-metadata-java libplexus-container-default-java
  libplexus-container-default1.5-java libplexus-containers-java libplexus-containers1.5-java libplexus-interactivity-api-java libplexus-interpolation-java libplexus-io-java libplexus-sec-dispatcher-java
  libplexus-utils-java libplexus-utils2-java libpolyglot-maven-java libqdox-java libqdox2-java libreflectasm-java librelaxng-datatype-java librhino-java libservlet3.1-java libsimple-http-java
  libsisu-inject-java libsisu-plexus-java libslf4j-java libspring-beans-java libspring-core-java libtaglibs-standard-impl-java libtaglibs-standard-spec-java libtomcat8-java libwagon-java libwagon2-java
  libxalan2-java libxbean-java libxerces2-java libxml-commons-external-java libxml-commons-resolver1.1-java libxom-java libxpp2-java libxpp3-java libxstream-java libyaml-snake-java testng unzip
0 upgraded, 148 newly installed, 0 to remove and 5 not upgraded.
Need to get 86.9 MB of archives.
After this operation, 126 MB of additional disk space will be used.
Do you want to continue? [Y/n] 

패키지 설치 후에 버전 확인 방법은 다음과 같다.

$ gradle -v

------------------------------------------------------------
Gradle 3.2.1
------------------------------------------------------------

Build time:   2012-12-21 00:00:00 UTC
Revision:     none

Groovy:       2.4.8
Ant:          Apache Ant(TM) version 1.9.9 compiled on July 22 2018
JVM:          1.8.0_222 (Oracle Corporation 25.222-b10)
OS:           Linux 4.9.0-9-amd64 amd64

3. 높은 버전 설치

apt-get으로 설치 시 gradle 버전을 높여서 설치하려고 할 때 add-apt-repository 명령을 사용한다.

3-1. add-apt-repository 설치

$ sudo apt-get install software-properties-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  gir1.2-glib-2.0 gir1.2-packagekitglib-1.0 iso-codes libcap2-bin libcurl3-gnutls libdbus-glib-1-2 libgirepository-1.0-1 libglib2.0-bin libgstreamer1.0-0 libpackagekit-glib2-18 libpam-cap libpam-systemd
  libpolkit-agent-1-0 libpolkit-backend-1-0 libpolkit-gobject-1-0 packagekit packagekit-tools policykit-1 python3-dbus python3-gi python3-pycurl python3-software-properties
Suggested packages:
  isoquery gstreamer1.0-tools appstream python-dbus-doc python3-dbus-dbg libcurl4-gnutls-dev python-pycurl-doc python3-pycurl-dbg
The following NEW packages will be installed:
  gir1.2-glib-2.0 gir1.2-packagekitglib-1.0 iso-codes libcap2-bin libcurl3-gnutls libdbus-glib-1-2 libgirepository-1.0-1 libglib2.0-bin libgstreamer1.0-0 libpackagekit-glib2-18 libpam-cap libpam-systemd
  libpolkit-agent-1-0 libpolkit-backend-1-0 libpolkit-gobject-1-0 packagekit packagekit-tools policykit-1 python3-dbus python3-gi python3-pycurl python3-software-properties software-properties-common
0 upgraded, 23 newly installed, 0 to remove and 5 not upgraded.
Need to get 8,688 kB of archives.
After this operation, 33.0 MB of additional disk space will be used.
Do you want to continue? [Y/n]

3-2. Repository 추가

$ sudo add-apt-repository ppa:cwchien/gradle
 Gradle is a Groovy based build system.

Gradle is build automation evolved. Gradle can automate the building, testing, publishing, deployment and more of software packages or other types of projects such as generated static websites, generated documentation or indeed anything else.

Gradle combines the power and flexibility of Ant with the dependency management and conventions of Maven into a more effective way to build. Powered by a Groovy DSL and packed with innovation, Gradle provides a declarative way to describe all kinds of builds through sensible defaults. Gradle is quickly becoming the build system of choice for many open source projects, leading edge enterprises and legacy automation challenges.

More info: 
 More info: https://launchpad.net/~cwchien/+archive/ubuntu/gradle
Press [ENTER] to continue or ctrl-c to cancel adding it

gpg: keybox '/tmp/tmp7tdl0gk1/pubring.gpg' created
gpg: /tmp/tmp7tdl0gk1/trustdb.gpg: trustdb created
gpg: key D7CC6F019D06AF36: public key "Launchpad PPA for Cheng-Wei Chien" imported
gpg: Total number processed: 1
gpg:               imported: 1
gpg: no valid OpenPGP data found.

그리고 나서 sudo apt-get update를 한번 실행한다.

$ sudo apt-get update
Hit:1 http://security.debian.org stretch/updates InRelease
Ign:2 http://deb.debian.org/debian stretch InRelease
Hit:3 http://deb.debian.org/debian stretch-updates InRelease
Hit:4 http://deb.debian.org/debian stretch-backports InRelease
Hit:5 http://deb.debian.org/debian stretch Release
Get:6 http://ppa.launchpad.net/cwchien/gradle/ubuntu eoan InRelease [15.4 kB]
Hit:7 http://packages.cloud.google.com/apt cloud-sdk-stretch InRelease
Hit:8 http://packages.cloud.google.com/apt google-compute-engine-stretch-stable InRelease
Hit:9 http://packages.cloud.google.com/apt google-cloud-packages-archive-keyring-stretch InRelease
Fetched 15.4 kB in 0s (22.2 kB/s)
Reading package lists... Done

만약 apt-get update 시 The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 에러가 발생한다면 여기를 참고하여 해결한다.

3-3. 설치

$ sudo apt-get install gradle
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  ant ant-optional antlr bnd glassfish-jmac-api groovy ivy java-wrappers javascript-common junit junit4 libantlr-java libaopalliance-java libapache-pom-java libasm-java libatinject-jsr330-api-java
  libbcel-java libbcpg-java libbcprov-java libbindex-java libbsf-java libbsh-java libcdi-api-java libcglib-java libclassworlds-java libcommons-cli-java libcommons-codec-java libcommons-collections3-java
  libcommons-dbcp-java libcommons-httpclient-java libcommons-io-java libcommons-lang-java libcommons-lang3-java libcommons-logging-java libcommons-net-java libcommons-parent-java libcommons-pool-java
  libdom4j-java libdoxia-core-java libeasymock-java libecj-java libeclipse-aether-java libfelix-osgi-obr-java libfindbugs-java libgeronimo-interceptor-3.0-spec-java libgoogle-gson-java libgpars-groovy-java
  libgradle-core-java libgradle-plugins-java libguava-java libguice-java libhamcrest-java libhawtjni-runtime-java libhttpclient-java libhttpcore-java libisorelax-java libjansi-java libjansi-native-java
  libjarjar-java libjatl-java libjaxen-java libjaxp1.3-java libjcifs-java libjcip-annotations-java libjcommander-java libjcsp-java libjdom1-java libjetty9-extra-java libjetty9-java libjformatstring-java
  libjline2-java libjna-java libjna-jni libjs-jquery libjsch-java libjsoup-java libjsr166y-java libjsr305-java libjzlib-java libkryo-java libkxml2-java liblog4j1.2-java liblogback-java libmail-java
  libmaven-parent-java libmaven2-core-java libmaven3-core-java libminlog-java libmsv-java libmultiverse-core-java libnative-platform-java libnative-platform-jni libnekohtml-java libnetty-3.9-java
  libobjenesis-java libosgi-annotation-java libosgi-compendium-java libosgi-core-java libplexus-ant-factory-java libplexus-archiver-java libplexus-bsh-factory-java libplexus-cipher-java
  libplexus-classworlds-java libplexus-classworlds2-java libplexus-cli-java libplexus-component-annotations-java libplexus-component-metadata-java libplexus-container-default-java
  libplexus-container-default1.5-java libplexus-containers-java libplexus-containers1.5-java libplexus-interactivity-api-java libplexus-interpolation-java libplexus-io-java libplexus-sec-dispatcher-java
  libplexus-utils-java libplexus-utils2-java libpolyglot-maven-java libqdox-java libqdox2-java libreflectasm-java librelaxng-datatype-java librhino-java libservlet3.1-java libsimple-http-java
  libsisu-inject-java libsisu-plexus-java libslf4j-java libspring-beans-java libspring-core-java libtaglibs-standard-impl-java libtaglibs-standard-spec-java libtomcat8-java libwagon-java libwagon2-java
  libxalan2-java libxbean-java libxerces2-java libxml-commons-external-java libxml-commons-resolver1.1-java libxom-java libxpp2-java libxpp3-java libxstream-java libyaml-snake-java testng unzip
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  gradle-5.5.1 gradle-ppa
The following NEW packages will be installed:
  gradle-5.5.1 gradle-ppa
The following packages will be upgraded:
  gradle
1 upgraded, 2 newly installed, 0 to remove and 5 not upgraded.
Need to get 89.1 MB of archives.
After this operation, 101 MB of additional disk space will be used.
Do you want to continue? [Y/n]

이제 5.5.1이 설치되었음을 알 수 있다.

$ gradle -v

Welcome to Gradle 5.5.1!

Here are the highlights of this release:
 - Kickstart Gradle plugin development with gradle init
 - Distribute organization-wide Gradle properties in custom Gradle distributions
 - Transform dependency artifacts on resolution

For more details see https://docs.gradle.org/5.5.1/release-notes.html


------------------------------------------------------------
Gradle 5.5.1
------------------------------------------------------------

Build time:   2019-07-10 20:38:12 UTC
Revision:     3245f748c7061472da4dc184991919810f7935a5

Kotlin:       1.3.31
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.14 compiled on March 12 2019
JVM:          1.8.0_222 (Oracle Corporation 25.222-b10)
OS:           Linux 4.9.0-9-amd64 amd64