[MNG-7038] Fixes for topDirectory (#1100)

Changes:
* resolve file argument against workingDirectory explicitly
* the check Files.isRegularFile should happen against path
This commit is contained in:
Tamas Cservenak 2023-05-02 20:37:56 +02:00 committed by GitHub
parent 8b8f2c3ddd
commit bec53b34e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -332,10 +332,10 @@ public class MavenCli {
for (String arg : cliRequest.args) { for (String arg : cliRequest.args) {
if (isAltFile) { if (isAltFile) {
// this is the argument following -f/--file // this is the argument following -f/--file
Path path = Paths.get(arg); Path path = topDirectory.resolve(arg);
if (Files.isDirectory(path)) { if (Files.isDirectory(path)) {
topDirectory = path; topDirectory = path;
} else if (Files.isRegularFile(topDirectory)) { } else if (Files.isRegularFile(path)) {
topDirectory = path.getParent(); topDirectory = path.getParent();
if (!Files.isDirectory(topDirectory)) { if (!Files.isDirectory(topDirectory)) {
System.err.println("Directory " + topDirectory System.err.println("Directory " + topDirectory