How to install specific version of maven in mac using brew command - macos

I want to install specific version (3.0.5) of maven in my using brew command. I tried the following command which is failed with Error: No available formula with the name "3.0.5"
brew install maven 3.0.5
Any ideas?

brew search maven
lists all maven versions as below
maven maven-completion maven-shell maven#3.0 maven#3.1 maven#3.2 ✔ maven#3.3
brew install maven#3.0
Installs maven 3.0.5 on my mac.

brew install https://raw.github.com/Homebrew/homebrew-versions/master/maven30.rb
it will then use a different Homebrew's formular which will give you the maven 3.0.5 instead
I tried this last on my Mac and it works installing the 3.0.5!
If none works and you can use similar version try the below:
brew install maven30
What OS do you have? On OS X 10.9 you should use brew install maven30 since maven 3.1.1 seems to be buggy.
By the way:
Using Homebrew:
you#host:~$ brew install maven will install Maven 3.3.1 (3/24/15)
you#host:~$ brew install maven30 will install Maven 3.0 which should be
better
If you got a 404 error, try doing a brew update just before.
If always nothing, try to recover the installation:
cd ~/Documents
mkdir BrewRecovery
cd BrewRecovery
curl -OL https://gist.githubusercontent.com/ilovezfs/21a741a78927a17b9ad1/raw/fef5866ccd51f07a9635fcb1096e8df0479af01b/Brewfile-deanchester.brewfile
md5 Brewfile-deanchester.brewfile

In general,
brew is unable to install any specific version such as 3.8.1
as it only gives few versions as the available options.
The only way then to install would be do it manually.
Also don't forget to update Path variable in your mac.

If you run brew install maven, the latest stable version would be installed.
If you want to install the previous versions you can run
brew install maven#versionNumber where versionNumber is your desired version.
Not all versions are available here in,
Also you may try hitting the website with the required version and download the file its available
https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/.
where you may substitute 3.6.1 with the version you want to run.

Related

Can you install disabled Homebrew packages?

> brew install maven#3.5
Error: maven#3.5 has been disabled because it is not maintained upstream!
I don't want to have to install Maven 3.5, but I need to install Maven 3.5. Can I force Homebrew to install this package it clearly knows about?
You can edit the formula with:
brew edit maven#3.5
Remove the line:
disable! date: "2022-07-31", because: :unmaintained
And install it with:
brew install maven#3.5

How to install maven with brew but without openjdk?

I already have Java HotSpot JDK 11 on my machine that I'm using for everything.
When I typed brew install maven it tried to install openjdk as a dependency. I don't want that and want maven to use my JDK, not its own openjdk.
So, how can I tell it to not install openjdk?
After installing java, I have installed Maven with command
brew install --ignore-dependencies maven
It worked for me, for Gradle also.
The way I solved it was installing the openjdk with brew (in my case openjdk#8). Mine was different from the default one that brew requires by default. So after that I created a symlink to my openjdk where maven is expecting to find the SDK. And finally installed maven without dependencies.
brew install openjdk#8
cd /usr/local/opt
ln -s ../Cellar/openjdk#8/1.8.0+275 openjdk
brew install --ignore-dependencies maven
I don't think there is a supported way to not install a dependency from the command line. However, you can configure the installed mvn to use another JDK. It requires two steps:
Add /usr/local/opt/maven/libexec/bin to your $PATH before /usr/local/bin to pick up the mvn script that does not override $JAVA_HOME
Set $JAVA_HOME in your environment or .mavenrc to pick up the your preferred version of Java
or (building on what Enrique Cordero said above) to re-use an already installed AdoptOpenJDK 8:
brew install adoptopenjdk8
cd /usr/local/opt
ln -s ../Caskroom/adoptopenjdk8/8,275:b01 ./openjdk
brew install maven --ignore-dependencies
and then remove the symlink
rm /usr/local/opt/openjdk
Not exactly the answer for the asked question, but if someone wants to change the JDK path from the default openjdk to the system defined JDK, one can do the following:
First, brew install maven - this will install maven (and openjdk) on the mac and point the default JDK used by maven to be this openjdk
Second, set JAVA_HOME in your ~/.bashrc or ~/.zshrc to point to sytem installed JDK
# set JAVA_HOME for mvn
export JAVA_HOME=`/usr/libexec/java_home`

When brew does not have latest package version

How do I force brew to install latest version of neovim (ver 0.5.0) when brew's formula only has 0.4.3?
I have tried:
brew update
brew upgrade neovim
And it says: Warning: neovim 0.4.3 already installed
I went brew's git repo and checked on neovim formula. Brew has neovim's 0.4.3, not 0.5.0. So brew update/upgrade is not going to help. https://github.com/Homebrew/homebrew-core/blob/master/Formula/neovim.rb
I'm thinking of just downloading neovim from neovim repo and installing it manually, but I'm afraid I'll have to manage updates and dependencies if I do this manual install.
curl -LO https://github.com/neovim/neovim/releases/download/nightly/nvim-macos.tar.gz
tar xzf nvim-macos.tar.gz
./nvim-osx64/bin/nvim
What should I do?
I fixed this with the following steps:
1) Unlink old neovim version:
brew unlink neovim ... and 2)
Install pointing to head:
brew install --HEAD neovim
... This installed neovim 0.5.0.
According to the brew doc, brew install --HEAD will install the master branch of the package. For neovim, it means that the latest version of neovim will be built for you, which may not be stable enough or even compile.
I suggest you install the nightly binary version of neovim. The best way to get the nightly version is to download from the binary release. No dependency is required to install if you download the binary release.
If you don't want to do this manually, you can write a bash script to automate this.

Switching Ruby versions using homebrew

One of the projects that I've been working has a dependency on ruby#2.3.
I'm using a Mac and the version of Ruby that I used for other projects is the 2.5.
I want to temporarily switch from 2.5 to 2.3 using brew. I don't want to use neither rbenv nor rvm.
1. I've installed the 2.3.7 version, using brew:
bf-old> brew install ruby#2.3
Warning: ruby#2.3 2.3.7 is already installed and up-to-date
To reinstall 2.3.7, run `brew reinstall ruby#2.3
2. I'm trying to switch to it, but it's not working:
bf-old> brew switch 2.3.7
Error: 2.3.7 not found in the Cellar.
What can I do about this?
Check if both the ruby versions are installed.
If both are installed, then try this:
brew unlink ruby#2.5 && brew link --force --overwrite ruby#2.3

How to install Qt 5.6.1-1 via homebrew?

When you run brew install qt5 you'll get the latest version (right now that's 5.7.0). A week ago or so, when I ran this command version 5.6.1-1 was installed.
Now I need to install this 5.6.1-1 version again on another machine. How can I do this via brew? (trying to avoid the long compile time)
A brew search qt5 doesn't show this previous release:
$ brew search qt5
pyqt5 qt5 ✔
homebrew/versions/qt52 homebrew/versions/qt55
The qt5 formula resides here, in Github and by backtracking to a previous commit you can find a previous version of the formula. The 5.6.1-1 version can be found here.
So to install Qt 5.6.1-1 with Homebrew you can do this:
curl -O https://raw.githubusercontent.com/Homebrew/homebrew-core/fdfc724dd532345f5c6cdf47dc43e99654e6a5fd/Formula/qt5.rb
brew install ./qt5.rb
brew install qt#5
From the other versions section of https://formulae.brew.sh/formula/qt

Resources