mirror of https://github.com/apache/maven.git
Fix search for topDirectory when using -f / --file
This commit is contained in:
parent
e39142b77a
commit
08e996bb28
|
@ -333,7 +333,7 @@ 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 = topDirectory.resolve(arg);
|
Path path = topDirectory.resolve(stripLeadingAndTrailingQuotes(arg));
|
||||||
if (Files.isDirectory(path)) {
|
if (Files.isDirectory(path)) {
|
||||||
topDirectory = path;
|
topDirectory = path;
|
||||||
} else if (Files.isRegularFile(path)) {
|
} else if (Files.isRegularFile(path)) {
|
||||||
|
@ -351,7 +351,7 @@ public class MavenCli {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
// Check if this is the -f/--file option
|
// Check if this is the -f/--file option
|
||||||
isAltFile = arg.equals(String.valueOf(CLIManager.ALTERNATE_POM_FILE)) || arg.equals("file");
|
isAltFile = arg.equals("-f") || arg.equals("--file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
topDirectory = getCanonicalPath(topDirectory);
|
topDirectory = getCanonicalPath(topDirectory);
|
||||||
|
@ -1616,6 +1616,18 @@ public class MavenCli {
|
||||||
return interpolator;
|
return interpolator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String stripLeadingAndTrailingQuotes(String str) {
|
||||||
|
final int length = str.length();
|
||||||
|
if (length > 1
|
||||||
|
&& str.startsWith("\"")
|
||||||
|
&& str.endsWith("\"")
|
||||||
|
&& str.substring(1, length - 1).indexOf('"') == -1) {
|
||||||
|
str = str.substring(1, length - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
private static Path getCanonicalPath(Path path) {
|
private static Path getCanonicalPath(Path path) {
|
||||||
try {
|
try {
|
||||||
return path.toRealPath();
|
return path.toRealPath();
|
||||||
|
|
Loading…
Reference in New Issue