-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
CLI: look for maven/gradle wrapper in parent dirs #20503
CLI: look for maven/gradle wrapper in parent dirs #20503
Conversation
To elaborate more on how this changes the usability, suppose you have a following multi-module project:
and that you navigate to The current behaviour is that the maven wrapper in the project root is not detected, so either a system installation of maven would be used by the The new behavior would be that |
I reviewed this a bit on Friday.. my only concern was the discovery backstop (how do you know when you've gone too far up the parent tree)... e.g. if the parent directory isn't a (maven/gradle) project, do you stop traversing? I do see that you are setting the target directory (in all cases) to the project root, so that is great. |
@ebullient no, there is no backstop until I meet the file system root ('/' or 'C:'). I agree it's bit simplistic, but I didn't get a better idea that would work :). Potential complications for smarter logic:
The proposed solution could break when there is |
BTW somebody mentioned mdub in the related issue, which does the same thing: https://github.com/dansomething/mdub/blob/master/bin/mw But I don't want to push it at all cost, if you don't find it reasonable. People have lived with the current functionality for some time... |
nono! Not resistant. Just paranoid. ;) I've done dumb things in my own systems looking for "stuff in the parent" .. so I'm just trying to understand when/how we determine we've backed out of the project tree entirely. mdub stops at root.. is that right? or should you stop as soon as you reach a directory that doesn't have a pom.xml/build.gradle file, or.. ? |
Yes, mdub stops at the file system root, which is what this PR currently does. In my opinion stopping at root is the most reasonable option, because it offers more predictable and understandable behavior to developers. Less magic - less potential for surprises. Worst case - CLI uses mvn wrapper it shouldn't have used. Trying to detect project roots by the presence of pom.xml / build.gradle will fail in some corner cases, that I described:
Worst case: CLI will not work in these cases. But it will work for most projects so the corner cases may be no big deal, there will always be some. I still feel better about the file system root. OTOH detecting pom.xml / build.gradle appears more defensive, so if you would prefer that I can rework :). |
Resolves #11516