Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNG-8069] add failing projects if a project is banned from reactor #1435

Open
wants to merge 1 commit into
base: maven-3.9.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.io.File;
import java.nio.file.Path;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;

Expand All @@ -28,8 +29,10 @@
import org.apache.maven.execution.BuildSuccess;
import org.apache.maven.execution.BuildSummary;
import org.apache.maven.execution.ExecutionEvent;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionResult;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.execution.ProjectDependencyGraph;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.project.MavenProject;
Expand Down Expand Up @@ -243,10 +246,44 @@ public void projectSkipped(ExecutionEvent event) {
if (logger.isInfoEnabled()) {
logger.info("");
infoLine('-');
MavenSession session = event.getSession();
MavenExecutionResult result = session.getResult();
ProjectDependencyGraph projectDependencyGraph = session.getProjectDependencyGraph();
List<MavenProject> upstreamProjects;
if (MavenExecutionRequest.REACTOR_FAIL_AT_END.equals(session.getReactorFailureBehavior())
&& projectDependencyGraph != null) {

// the project is blacklisted only so one of its upstreams must have failed here...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't quite follow this comment, please rephrase

upstreamProjects = projectDependencyGraph.getUpstreamProjects(event.getProject(), true);
} else {
// any other failure must have lead to this so any projects is eligible
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are eligible

upstreamProjects = session.getProjects();
}
// now collect all failing projects order by their ID

infoMain("Skipping " + event.getProject().getName());
logger.info("This project has been banned from the build due to previous failures.");

upstreamProjects.stream()
.map(result::getBuildSummary)
.filter(BuildFailure.class::isInstance)
.map(BuildFailure.class::cast)
.sorted(Comparator.comparing(
BuildFailure::getProject,
Comparator.comparing(MavenProject::getId, String.CASE_INSENSITIVE_ORDER)))
.forEach(buildfailure -> {
String reason;
Throwable cause = buildfailure.getCause();
if (cause == null) {
reason = "failed!";
} else {
reason = cause.getClass().getSimpleName();
String message = cause.getMessage();
if (message != null) {
message += ": " + message;
}
}
logger.info(" - " + buildfailure.getProject().getId() + ": " + reason);
});
infoLine('-');
}
}
Expand Down
Loading