Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install specific version of gradle

Tags:

gradle

I have to work on a project that runs with Gradle 2.2.

I would like to install Gradle 2.2 in order to make the project build fine. But I don't know how to do that, I only can install Gradle latest version. Is there a way to install a specific version of Gradle?

I work on ubuntu 14.04 LTS.

like image 823
thomas Avatar asked Dec 19 '17 09:12

thomas


People also ask

Can I install multiple versions of Gradle?

To change that, you need to change the PATH variable. There are also tools like sdkman and similar that can switch between different Gradle versions. But actually you shouldn't really need that, or even need an installed Gradle version, let alone two.


1 Answers

You can use SDKMAN! to manage different Gradle versions. After installing it you can do:

sdk list gradle

to see all available Gradle versions:

================================================================================
Available Gradle Versions
================================================================================
     4.4-rc-6             4.2-rc-1             2.9                  2.1            
     4.4-rc-5             4.2                  2.8                  2.0            
     4.4-rc-4             4.1                  2.7                  1.9            
     4.4-rc-3             4.0.2                2.6                  1.8            
     4.4-rc-2             4.0.1                2.5                  1.7            
     4.4-rc-1             4.0                  2.4                  1.6            
     4.4                  3.5.1                2.3                  1.5            
 > * 4.3.1                3.5                  2.2.1                1.4            
     4.3-rc-4             3.4.1                2.2                  1.3            
     4.3-rc-3             3.4                  2.14.1               1.2            
     4.3-rc-2             3.3                  2.14                 1.12           
     4.3-rc-1             3.2.1                2.13                 1.11           
     4.3                  3.2                  2.12                 1.10           
     4.2.1                3.1                  2.11                 1.1            
     4.2-rc-2             3.0                  2.10                 1.0            

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

Then you can do:

sdk install gradle [version]

where [version] is your desired version.

Using Gradle Wrapper

There is also alternative way to provide Gradle to your project. You can add Gradle Wrapper with specific version, so you don't have to worry about installing local Gradle.

If you have Gradle already installed in your local machine you can simply do:

gradle wrapper --gradle-version [version]

where [version] is your desired version number. When adding wrapper is completed you will find e.g. gradlew file in the root directory of your project. Make it executable with:

chmod +x gradlew

and then you can run Gradle using this script instead of using local Gradle distribution:

./gradlew clean test 

for example.

Gradle Wrapper allows you to share same Gradle distribution across all team members that participate in project (simply add all wrapper files to your Git or any other repository).

like image 80
Szymon Stepniak Avatar answered Oct 18 '22 17:10

Szymon Stepniak