Search code examples
gradlemacportsversions

Select version of Gradle using Macports?


I'm working on a project at the moment which is only compatible with Gradle 3.5. You can see below that I'm running Gradle 4.0 at the moment and would like to downgrade, preferably whilst continuing to use Macports to manage the install.

The question is, how can I choose to use gradle @3.5_0?


My first port of call was to uninstall Gradle and re-install using an alternate means. When uninstalling (below) I spotted that I do have Gradle 3.5, I just need to activate it.

matt@macbook ~ $ sudo port uninstall gradle
Password:
The following versions of gradle are currently installed:
 1) gradle @3.2.1_0
 2) gradle @3.3_0
 3) gradle @3.5_0
 4) gradle @4.0_0
 5) gradle @4.0.1_0 (active)
Enter option(s) [1-5/all]: 4
--->  Uninstalling gradle @4.0_0

The standard Macports way to do that is to use select, but that didn't work, as below:

matt@macbook ~ $ port select gradle @3.5_0
Selecting '@3.5_0' for 'gradle' failed: The specified group 'gradle' does not exist.

The select command relies on Macports being aware that multiple versions exist and can be selected. According to Macports, no such list exists for Gradle, as below:

matt@viking ~ $ port select gradle
Warning: Unable to get active selected version: The specified group 'gradle' does not exist.
Error: The 'list' command failed: The specified group 'gradle' does not exist.


Solution

  • As long as you still have gradle installed but deactivated, you can run sudo port activate gradle @3.5_0. Note that this will only work if you previously disabled the currently active gradle port.

    port select is only for ports that support having multiple versions installed side by side, which is not the case for the gradle port. See port help select for more information on the select mechanism.

    For extensive documentation on working with older ports, see also the the howto page on this topic: https://trac.macports.org/wiki/howto/InstallingOlderPort.