SDKMANでGradle

# プロダクトページ
[sdkman](http://sdkman.io/)
[github](https://github.com/sdkman/sdkman-cli)

## 先に準備するもの
curlコマンド
```
$ apt-get install curl
```

## sdkmanのインストール
```
$ curl -s api.sdkman.io | bash
                                                               		         
Thanks for using...                                            		         
                                                               		         
                                                               		         
     SSSSSSSSSSSSSSS DDDDDDDDDDDDD       KKKKKKKKK    KKKKKKK                  
   SS:::::::::::::::SD::::::::::::DDD    K:::::::K    K:::::K                  
  S:::::SSSSSS::::::SD:::::::::::::::DD  K:::::::K    K:::::K                  
  S:::::S     SSSSSSSDDD:::::DDDDD:::::D K:::::::K   K::::::K                  
  S:::::S              D:::::D    D:::::DKK::::::K  K:::::KKK                  
  S:::::S              D:::::D     D:::::D K:::::K K:::::K                     
   S::::SSSS           D:::::D     D:::::D K::::::K:::::K                      
    SS::::::SSSSS      D:::::D     D:::::D K:::::::::::K                       
      SSS::::::::SS    D:::::D     D:::::D K:::::::::::K                       
         SSSSSS::::S   D:::::D     D:::::D K::::::K:::::K                      
              S:::::S  D:::::D     D:::::D K:::::K K:::::K                     
              S:::::S  D:::::D    D:::::DKK::::::K  K:::::KKK                  
  SSSSSSS     S:::::SDDD:::::DDDDD:::::D K:::::::K   K::::::K                  
  S::::::SSSSSS:::::SD:::::::::::::::DD  K:::::::K    K:::::K                  
  S:::::::::::::::SS D::::::::::::DDD    K:::::::K    K:::::K                  
   SSSSSSSSSSSSSSS   DDDDDDDDDDDDD       KKKKKKKKK    KKKKKKK                  
                                                                               
                                                                               
                      mmmmmmm    mmmmmmm     aaaaaaaaaaaaa  nnnn  nnnnnnnn     
                    mm:::::::m  m:::::::mm   a::::::::::::a n:::nn::::::::nn   
                   m::::::::::mm::::::::::m  aaaaaaaaa:::::an::::::::::::::nn  
                   m::::::::::::::::::::::m           a::::ann:::::::::::::::n 
                   m:::::mmm::::::mmm:::::m    aaaaaaa:::::a  n:::::nnnn:::::n 
                   m::::m   m::::m   m::::m  aa::::::::::::a  n::::n    n::::n 
                   m::::m   m::::m   m::::m a::::aaaa::::::a  n::::n    n::::n 
                   m::::m   m::::m   m::::ma::::a    a:::::a  n::::n    n::::n 
                   m::::m   m::::m   m::::ma::::a    a:::::a  n::::n    n::::n 
                   m::::m   m::::m   m::::ma:::::aaaa::::::a  n::::n    n::::n 
                   m::::m   m::::m   m::::m a::::::::::aa:::a n::::n    n::::n 
                   mmmmmm   mmmmmm   mmmmmm  aaaaaaaaaa  aaaa nnnnnn    nnnnnn 
            								                                     
            								                                     
                                                 Now attempting installation...
                                                                               
Looking for a previous installation of SDKMAN...
Looking for unzip...
Looking for curl...
Looking for sed...
Installing SDKMAN scripts...
Create distribution directories...
Getting available candidates...
Prime the config file...
Download script archive...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:23 --:--:--     0
100 19384  100 19384    0     0    804      0  0:00:24  0:00:24 --:--:--   804
Extract script archive...
Install scripts...
Set version to 4.0.32 ...
Attempt update of bash profiles...
```

最後に下記のようなメッセージが
次に実行するコマンドが出てくるなんて親切ですね(^^)
```
All done!


Please open a new terminal, or run the following in the existing one:

    source "~/.sdkman/bin/sdkman-init.sh"

Then issue the following command:

    sdk help

Enjoy!!!
```

ということで実行

```bash
$ source "/home/kamimura/.sdkman/bin/sdkman-init.sh"
```
これは特にメッセージなし

## gradleをインストール
まずはバージョンを確認

```bash
$ gvm list gradle
==== BROADCAST =================================================================
* 14/04/16: Grails 3.0.16 released on SDKMAN! #grailsfw
* 14/04/16: Grails 3.1.5 released on SDKMAN! #grailsfw
* 07/04/16: Sshoogr 0.9.25 released on SDKMAN! #sshoogr
================================================================================

================================================================================
Available Gradle Versions
================================================================================
     2.9                  2.0                  0.9.1                               
     2.8                  1.9                  0.9                                 
     2.7                  1.8                  0.8                                 
     2.6                  1.7                  0.7                                 
     2.5                  1.6                                                      
     2.4                  1.5                                                      
     2.3                  1.4                                                      
     2.2.1                1.3                                                      
     2.2                  1.2                                                      
     2.13-rc-1            1.12                                                     
     2.12-rc-1            1.11                                                     
     2.12                 1.10                                                     
     2.11                 1.1                                                      
     2.10                 1.0                                                      
     2.1                  0.9.2                                                    

================================================================================
+ - local version
* - installed
> - currently in use
================================================================================
```

まずは2.10をインストール

```bash
$ gvm install gradle 2.10

Downloading: gradle 2.10

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   355    0   355    0     0    164      0 --:--:--  0:00:02 --:--:--   380
100 44.2M  100 44.2M    0     0  2546k      0  0:00:17  0:00:17 --:--:-- 3014k

Installing: gradle 2.10
Done installing!

Do you want gradle 2.10 to be set as default? (Y/n): y

Setting gradle 2.10 as default.
```

2.12をインストール（こっちをオプションにしてみます）

```bash

$ gvm install gradle 2.12

Downloading: gradle 2.12

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   355    0   355    0     0    255      0 --:--:--  0:00:01 --:--:--     0
100 44.7M  100 44.7M    0     0  2737k      0  0:00:16  0:00:16 --:--:-- 3161k

Installing: gradle 2.12
Done installing!

Do you want gradle 2.12 to be set as default? (Y/n): n
```

バージョンを確認してみる

```bash

$ gradle -version

------------------------------------------------------------
Gradle 2.10
------------------------------------------------------------

Build time:   2015-12-21 21:15:04 UTC
Build number: none
Revision:     276bdcded730f53aa8c11b479986aafa58e124a6

Groovy:       2.4.4
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM:          1.8.0_45-internal (Oracle Corporation 25.45-b02)
OS:           Linux 3.19.0-58-generic amd64
```
ちゃんと2.10ですね
あたりまえか(^^; 

2.12に切り替えてみる

```bash
$ gvm u gradle 2.12

Using gradle version 2.12 in this shell.

$ gradle -version

------------------------------------------------------------
Gradle 2.12
------------------------------------------------------------

Build time:   2016-03-14 08:32:03 UTC
Build number: none
Revision:     b29fbb64ad6b068cb3f05f7e40dc670472129bc0

Groovy:       2.4.4
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM:          1.8.0_45-internal (Oracle Corporation 25.45-b02)
OS:           Linux 3.19.0-58-generic amd64

```
切り替わったー！