Pankraz76 commented on code in PR #2304:
URL: https://github.com/apache/maven/pull/2304#discussion_r2079665241


##########
impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelProcessor.java:
##########
@@ -94,50 +97,45 @@ public Path locateExistingPom(Path projectDirectory) {
         return pom;
     }
 
+    private Path doLocateExistingPom(Path project) {
+        if (project == null) {
+            project = Paths.get(System.getProperty("user.dir"));
+        } else if (Files.isDirectory(project)) {
+            Path pom = project.resolve("pom.xml");
+            return Files.isRegularFile(pom) ? pom : null;
+        }
+        return project;
+    }
+
     @Override
     public Model read(XmlReaderRequest request) throws IOException {
-        Objects.requireNonNull(request, "source cannot be null");
-        Path pomFile = request.getPath();
+        Path pomFile = requireNonNull(request, "source cannot be 
null").getPath();
         if (pomFile != null) {
-            Path projectDirectory = pomFile.getParent();
             List<ModelParserException> exceptions = new ArrayList<>();
             for (ModelParser parser : modelParsers) {
                 try {
-                    Optional<Model> model =
-                            parser.locateAndParse(projectDirectory, 
Map.of(ModelParser.STRICT, request.isStrict()));
-                    if (model.isPresent()) {
-                        return model.get().withPomFile(pomFile);
+                    Optional<Model> parent = parent(request, parser, 
pomFile.getParent());
+                    if (parent.isPresent()) {
+                        return parent.get().withPomFile(pomFile);
                     }
                 } catch (ModelParserException e) {
                     exceptions.add(e);

Review Comment:
   is it mandatory `to continue if an error occurs` to give full error report? 
Or can we have here early exit if the branch kicks in like above in its 
counterpart?



-- 
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]

Reply via email to