[
https://issues.apache.org/jira/browse/MNG-7862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17758011#comment-17758011
]
ASF GitHub Bot commented on MNG-7862:
-------------------------------------
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.
> The ModelLocator should always be used when locating pom.xml
> ------------------------------------------------------------
>
> Key: MNG-7862
> URL: https://issues.apache.org/jira/browse/MNG-7862
> Project: Maven
> Issue Type: Improvement
> Affects Versions: 4.0.0-alpha-7
> Reporter: Guillaume Nodet
> Assignee: Guillaume Nodet
> Priority: Major
> Fix For: 4.0.0-alpha-8
>
>
> There are a few places where the pom.xml location is hardcoded. There's a
> known interface to locate those, so those references should be cleaned.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)