[MNG-7788] Plugin Validation Report logged before summary ()

This change uses different technique to hook into "session end", and thus is invoked before ExecutionEventLogger is.

---

https://issues.apache.org/jira/browse/MNG-7788
This commit is contained in:
Tamas Cservenak 2023-05-19 17:47:32 +02:00
parent 11d97e64e7
commit 099a3f346c
1 changed files with 10 additions and 5 deletions
maven-core/src/main/java/org/apache/maven/plugin/internal

View File

@ -29,7 +29,8 @@ import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.maven.AbstractMavenLifecycleParticipant;
import org.apache.maven.eventspy.AbstractEventSpy;
import org.apache.maven.execution.ExecutionEvent;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.InputLocation;
import org.apache.maven.plugin.PluginValidationManager;
@ -44,8 +45,7 @@ import org.slf4j.LoggerFactory;
@Singleton
@Named
public final class DefaultPluginValidationManager extends AbstractMavenLifecycleParticipant
implements PluginValidationManager {
public final class DefaultPluginValidationManager extends AbstractEventSpy implements PluginValidationManager {
private static final String ISSUES_KEY = DefaultPluginValidationManager.class.getName() + ".issues";
@ -62,8 +62,13 @@ public final class DefaultPluginValidationManager extends AbstractMavenLifecycle
private final Logger logger = LoggerFactory.getLogger(getClass());
@Override
public void afterSessionEnd(MavenSession session) {
reportSessionCollectedValidationIssues(session);
public void onEvent(Object event) {
if (event instanceof ExecutionEvent) {
ExecutionEvent executionEvent = (ExecutionEvent) event;
if (executionEvent.getType() == ExecutionEvent.Type.SessionEnded) {
reportSessionCollectedValidationIssues(executionEvent.getSession());
}
}
}
private ValidationReportLevel validationReportLevel(RepositorySystemSession session) {