gnodet commented on code in PR #1217:
URL: https://github.com/apache/maven/pull/1217#discussion_r1302974739
##########
maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java:
##########
@@ -1349,23 +1349,20 @@ private File determinePom(final CommandLine
commandLine, final String workingDir
alternatePomFile =
commandLine.getOptionValue(CLIManager.ALTERNATE_POM_FILE);
}
+ File current = baseDirectory;
if (alternatePomFile != null) {
- File pom = resolveFile(new File(alternatePomFile),
workingDirectory);
- if (pom.isDirectory()) {
- if (modelProcessor != null) {
- pom = modelProcessor.locatePom(pom);
- } else {
- pom = new File(pom, "pom.xml");
- }
- }
+ current = resolveFile(new File(alternatePomFile),
workingDirectory);
+ }
- return pom;
- } else if (modelProcessor != null) {
- File pom = modelProcessor.locatePom(baseDirectory);
+ File pom;
+ if (current.isDirectory() && modelProcessor != null) {
+ pom = modelProcessor.locatePom(current);
+ } else {
+ pom = current;
+ }
- if (pom.isFile()) {
- return pom;
- }
+ if (pom.isFile()) {
Review Comment:
I tried, but the logic is expected downstream, mostly when you run Maven
inside a directory with no `pom.xml`. In such cases, a `null` value is
expected. Also, the `modelLocator` is required to always return a value, but
can point to a non existent file, hence the check.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]