gnodet commented on code in PR #13792:
URL: https://github.com/apache/maven/pull/13792#discussion_r4481045185
##########
impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvn/MavenInvoker.java:
##########
@@ -528,6 +531,69 @@ protected int doExecute(MavenContext context,
MavenExecutionRequest request) thr
}
}
+ /**
+ * When an {@link ArtifactFilteredOutException} is found in the exception
chain, log a reactor-aware hint
+ * that precisely identifies whether the artifact is an unselected
project, an already-selected project, or
+ * a pure repository-manager configuration issue.
+ */
+ protected void logFilteredOutHint(MavenContext context, Throwable
exception, MavenExecutionResult result) {
+ ArtifactFilteredOutException filteredOut = findCause(exception,
ArtifactFilteredOutException.class);
+ if (filteredOut == null) {
+ return;
+ }
+
+ Artifact artifact = filteredOut.getArtifact();
+ if (artifact == null) {
+ return;
+ }
+
+ String groupId = artifact.getGroupId();
+ String artifactId = artifact.getArtifactId();
+ String version = artifact.getVersion();
+ String coords = groupId + ":" + artifactId + ":" + version;
+
+ List<MavenProject> allProjects = result.getAllProjects();
+ List<MavenProject> selectedProjects =
result.getTopologicallySortedProjects();
+
+ boolean inAll = allProjects.stream()
+ .anyMatch(p -> p.getGroupId().equals(groupId)
+ && p.getArtifactId().equals(artifactId)
+ && p.getVersion().equals(version));
+ boolean inSelected = selectedProjects.stream()
+ .anyMatch(p -> p.getGroupId().equals(groupId)
+ && p.getArtifactId().equals(artifactId)
+ && p.getVersion().equals(version));
+
+ context.logger.error("");
+ if (inAll && !inSelected) {
+ context.logger.error(coords
+ + " is a project of this build but was not selected."
+ + " Add -am to also build its dependencies, or run the
full reactor.");
+ } else if (inAll) {
+ context.logger.error(coords
+ + " is part of this build but has not been built yet."
+ + " Build it first or reorder the reactor.");
+ } else {
+ context.logger.error("This error indicates that a remote
repository filter has rejected " + coords + "."
+ + " This commonly happens with repository managers using
virtual/group repositories"
+ + " that do not properly aggregate prefix files.");
+ context.logger.error("To disable remote repository filtering, add
one or both of these to your command line"
+ + " or to .mvn/maven.config:");
+ context.logger.error("
-Daether.remoteRepositoryFilter.prefixes=false");
+ context.logger.error("
-Daether.remoteRepositoryFilter.groupId=false");
+ context.logger.error("See
https://maven.apache.org/resolver/remote-repository-filtering.html");
+ }
+ }
+
+ private static <T extends Throwable> T findCause(Throwable exception,
Class<T> type) {
+ for (Throwable t = exception; t != null && t != t.getCause(); t =
t.getCause()) {
Review Comment:
<!-- hermes-review -->
Already addressed: `findCause` now uses `IdentityHashMap<Throwable,
Boolean>` with `seen.put(t, Boolean.TRUE) == null` as the loop guard —
equivalent to `dejaVu` in `DefaultExceptionHandler`. Direct self-loops, two-hop
cycles, and arbitrary-length cycles are all handled correctly.
--
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]