Ballerina tool for distribution management

Tharik Kanaka
Ballerina Swan Lake Tech Blog
3 min readDec 26, 2019

Ballerina is evolving continuously and there will be releases frequently. Previously you need to visit website and download installers to get updated. Along with the Ballerina 1.1.0 release, Ballerina tool has been introduced. You can download latest installer from the website. Hope this will be last time you need to do that :)

Once you have installed Ballerina 1.1.0 and if you run version option as below, now it shows Ballerina tool version as 0.8.0.

ballerina -v
jBallerina 1.1.0
Language specification 2019R3
Ballerina tool 0.8.0

Then if you run ballerina help command it will show new 2 commands in the bottom.

ballerina help..
..
Update Commands:
dist Manage Ballerina distributions
update Update the Ballerina tool

Here dist command consist of sub commands to manage ballerina distributions. For more information you can run ballerina distribution help commands as below

ballerina help dist..
..

update Update to the latest patch version of the active distribution
pull Fetch a distribution and set it as the active version
use Set a distribution as the active distribution
list List locally and remotely available distributions
remove Remove distributions in your local environment

Here i would start from listing all the distributions by running the list commands as below

ballerina dist list
Distributions available locally:
* jballerina-1.1.0Distributions available remotely: jballerina-1.0.5
jballerina-1.0.4
jballerina-1.0.3
jballerina-1.0.2
jballerina-1.0.1
jballerina-1.0.0

Here you have the latest version so its been marked as * and also it will list down distributions available in the remotely as well. Using list command you can check whether are there any version new versions. In future we will be including 1.1.1 or 1.2.0 distributions in the list as we release them.

For demo purpose i will be downloading jballerina-1.0.0 distribution and set it as active version with the pull command as below.

ballerina dist pull jballerina-1.0.0Fetching the 'jballerina-1.0.0' distribution from the remote server...Downloading jballerina-1.0.0 100% [==============================================================] 99/99 MB (0:00:49 / 0:00:00)  'jballerina-1.0.0' successfully set as the active distribution

With ballerina dist pull <distribution>, you can pull any version. <distribution> consist of distribution type (jballerina) and the version(1.0.0) separated by a dash.

As now i have pulled 1.0.0 release, i can run ballerina dist list command again to see what it has changed.

ballerina dist list 
Distributions available locally:
jballerina-1.1.0
* jballerina-1.0.0
Distributions available remotely: jballerina-1.0.5
jballerina-1.0.4
jballerina-1.0.3
jballerina-1.0.2
jballerina-1.0.1
Use ‘ballerina help dist’ for more information on specific commands.

Here now its listing 1.1.0 distribution under local distributions and marked it has the active one. If you carefully noticed that particular distribution has been removed from the remote list as its already pulled.

Now lets see what if we run ballerina dist update command.

ballerina dist updateFetching the latest patch distribution for ‘jballerina-1.0.0’ from the remote server…Fetching the ‘jballerina-1.0.5’ distribution from the remote server…Downloading jballerina-1.0.5 100% [==============================================================] 96/96 MB (0:00:33 / 0:00:00) Successfully set the latest patch distribution ‘jballerina-1.0.5’ as the active distribution

Here its figuring out the latest patch version which 1.0.5 , then fetching that version and setting it as the active distribution.

Imagine if you are using jballerina-1.1.0 distribution and if you want to get latest patch version, you only need to run ballerina dist update command.

When you have multiple version locally and you need to use a particular version you can use ballerina dist use <distribution> command.

Then if you want to remove any distribution locally you can use ballerina dist remove <distribution> command.

Finally there is ballerina update command to update the tool itself. This is only required once we do a new Ballerina tool release. Currently 0.8.0 is the latest version.

Now you don’t need to download installers for future releases, Ballerina tool will get everything for you.

--

--