elharo commented on code in PR #1197:
URL: https://github.com/apache/maven/pull/1197#discussion_r1331486002
##########
maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProcessor.java:
##########
@@ -95,8 +114,15 @@ public File locateExistingPom(File projectDirectory) {
public Path locateExistingPom(Path projectDirectory) {
// Note that the ModelProcessor#locatePom never returns null
- File f = modelLocator.locateExistingPom(projectDirectory.toFile());
- Path pom = f != null ? f.toPath() : null;
+ // while the ModelParser#locatePom needs to return an existing path!
+ Path pom = modelParsers.stream()
+ .map(m -> m.locate(projectDirectory).map(s ->
s.getPath()).orElse(null))
+ .filter(Objects::nonNull)
+ .findFirst()
+ .orElseGet(() -> {
+ File f =
modelLocator.locateExistingPom(projectDirectory.toFile());
Review Comment:
I know this is a common belief, but it's not how exceptions in Java were
designed and it doesn't work in practice.
https://www.youtube.com/watch?v=rJ-Ihh7RNao
--
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]