Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No need of using M2_HOME environment variable as fallback to find path to maven executable in Windows #4288

Open
algomaster99 opened this issue Nov 15, 2021 · 6 comments

Comments

@algomaster99
Copy link
Contributor

algomaster99 commented Nov 15, 2021

We no longer need to get the path to maven executable via M2_HOME because its usage has been deprecated with newer Windows releases.

EDIT:
Support for M2_HOME was deprecated in Maven 3.5.0. See 5th point in the overview about the changes.

@algomaster99 algomaster99 changed the title No need for using M2_HOME environment variable as fallback to find path to maven executable in Windows No need of using M2_HOME environment variable as fallback to find path to maven executable in Windows Nov 15, 2021
@slarse
Copy link
Collaborator

slarse commented Nov 15, 2021

Could you try to find the actual release notes for when this M2_HOME was deprecated and/or removed? From the Maven release notes that is.

The links here just refer to it as "being gone", or something like that.

@algomaster99
Copy link
Contributor Author

@slarse Yes, I can find that. I once looked up release notes of Windows environment which just hit me that it was the wrong place to look at. I will try finding it on the Apache maven website.

@algomaster99
Copy link
Contributor Author

@slarse , found it! Look at the updated issue description.

@slarse
Copy link
Collaborator

slarse commented Nov 15, 2021

@algomaster99 Good find.

I don't think it's a good idea to remove the M2_HOME fallback yet. Maven 3.5 is relatively recent (released in 2017). Up until relatively recently, we were running Maven 3.3 on Jenkins, and releases as old as Maven 3.1 are still supported. As there are still-supported releases where using M2_HOME is an entirely valid practice, it doesn't seem right to remove it outright.

There are however a couple of action points.

At the very least, we shouldn't mention M2_HOME when we can't find the Maven binary, only that the binary/program couldn't be found. The error message should advice the user to ensure that the binary is on path (system path for Windows, I believe). I suspect that the current error message (""M2_HOME must be initialized to use this MavenLauncher constructor.") was written before guessMavenHome() was implemented, and only M2_HOME was used.

We could go a step further and log a warning if we have to use the M2_HOME fallback, and advise the user to put the Maven binary on the path.

@algomaster99
Copy link
Contributor Author

Summarising the above comment,

@slarse
Copy link
Collaborator

slarse commented Nov 27, 2021

If we want to be super nice about it, we should only log a warning message if using M2_HOME with Maven version 3.5.0 or later. Because before that, M2_HOME was fair game.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants