0

Scenario

While trying to install gradle 5.5+ from a powershell script in windows, on WSL Ubuntu 16.04, I experienced mild technical difficulties.

Attempts

  1. Following approach 2. of https://howtoprogram.xyz/2016/09/06/install-gradle-ubuntu-16-04/, SDKMAN would not be registred from powershell with sdk help even though it would inside the WSL itself. And Restart-Service LxssManager from Rebooting Ubuntu on Windows without rebooting Windows? did not ensure SDKMAN was registered either.
  2. https://linux4one.com/how-to-install-gradle-on-ubuntu-18-04/ required Setting up Environment Variables with export which has been challenging for me in combination with piping outputs in the past.
  3. Same argument as in 2: https://www.vultr.com/docs/how-to-install-gradle-on-ubuntu-16-10
  4. https://howtoprogram.xyz/2016/09/06/install-gradle-ubuntu-16-04/ requests writing with vi which can be non-trivial with powershell.
  5. sudo apt install gradle installed gradle 2.10 instead of 5.5+.
  6. This github instructions returned couldn't find gradle 3.1

Question

How can one automatically install gradle V5.5+ in WSL Ubuntu 16.04 from Windows with a (powershell) script?

a.t.
  • 453

1 Answers1

0

A solution was found by combining the following two instructions:

Yielding instruction set:

sudo add-apt-repository ppa:openjdk-r/ppa
sudo add-apt-repository ppa:cwchien/gradle

sudo apt-get update

sudo apt-get install openjdk-8-jre
sudo apt-get install gradle-ppa

Which, converted into a powershell script (that in the first line installs the WSL Ubuntu 16.04) can look like:

lxrun /install /y
bash -c "yes | sudo add-apt-repository ppa:openjdk-r/ppa"
bash -c "yes | sudo add-apt-repository ppa:cwchien/gradle"

bash -c "yes | sudo apt-get update"

bash -c "yes | sudo apt-get install openjdk-8-jre"
bash -c "yes | sudo apt-get install gradle-ppa"

I hope it helps someone.

a.t.
  • 453