You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "gnodet-bot (via GitHub)" <gi...@apache.org> on 2026/09/15 19:46:11 UTC
Re: [PR] [MNG-6797] Remember if Maven model problems were encountered. [maven]
gnodet-bot commented on code in PR #298:
URL: https://github.com/apache/maven/pull/298#discussion_r4019573571
##########
maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java:
##########
@@ -342,11 +342,12 @@ private List<MavenProject> getProjectsForMavenReactor(MavenSession session) thro
}
List<File> files = Arrays.asList(request.getPom().getAbsoluteFile());
- collectProjects(projects, files, request);
+ boolean problems = collectProjects(projects, files, request);
+ session.setModelProblems(problems);
Review Comment:
⚠️ **Pomless path skipped**: the early-return branch for `request.getPom() == null` (around line 333) never calls `setModelProblems()`, leaving the session at `false` even if the standalone project has problems. This line is only reached when a POM file is present.
Add `session.setModelProblems(false)` before the early `return projects;` in the pomless branch, or restructure to have a single return point so `setModelProblems()` is always called.
##########
maven-core/src/main/java/org/apache/maven/execution/MavenSession.java:
##########
@@ -253,6 +255,26 @@ public void setParallel(boolean parallel) {
this.parallel = parallel;
}
+ /**
+ * Indicates whether any problems were detected while building the Maven models.
+ *
+ * @return {@code true} if model problems were detected, {@code false} otherwise
+ * @since 3.10.0
+ */
+ public boolean hasModelProblems() {
+ return modelProblems;
+ }
+
+ /**
+ * Records whether any problems were detected while building the Maven models.
+ *
+ * @param modelProblems whether model problems were detected
+ * @since 3.10.0
+ */
+ public void setModelProblems(boolean modelProblems) {
+ this.modelProblems = modelProblems;
+ }
+
public RepositorySystemSession getRepositorySession() {
Review Comment:
⚠️ **Resettable flag**: `setModelProblems(boolean)` accepts `false`, meaning it can clear a previously-set `true`. The API contract should either be documented as "call at most once per build" or changed to an additive setter:
```suggestion
public void setModelProblems() {
this.modelProblems = true;
}
```
This makes the flag monotonic and prevents accidental resets by callers passing `false`.
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org