[MNG-7823] Improve plugin validation level parsing (#1182)

Changes:
* always parse it at session start
* hence, will WARN if needed there as well, and will warn once
* do not re-parse and possibly warn always, reuse parsed enum

---

https://issues.apache.org/jira/browse/MNG-7823
This commit is contained in:
Tamas Cservenak 2023-06-23 13:04:57 +02:00 committed by GitHub
parent b050257c05
commit 958112991d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -83,13 +83,22 @@ public final class DefaultPluginValidationManager extends AbstractEventSpy imple
public void onEvent(Object event) {
if (event instanceof ExecutionEvent) {
ExecutionEvent executionEvent = (ExecutionEvent) event;
if (executionEvent.getType() == ExecutionEvent.Type.SessionEnded) {
if (executionEvent.getType() == ExecutionEvent.Type.SessionStarted) {
RepositorySystemSession repositorySystemSession =
executionEvent.getSession().getRepositorySession();
validationReportLevel(repositorySystemSession); // this will parse and store it in session.data
} else if (executionEvent.getType() == ExecutionEvent.Type.SessionEnded) {
reportSessionCollectedValidationIssues(executionEvent.getSession());
}
}
}
private ValidationReportLevel validationReportLevel(RepositorySystemSession session) {
return (ValidationReportLevel) session.getData()
.computeIfAbsent(ValidationReportLevel.class, () -> parseValidationReportLevel(session));
}
private ValidationReportLevel parseValidationReportLevel(RepositorySystemSession session) {
String level = ConfigUtils.getString(session, null, MAVEN_PLUGIN_VALIDATION_KEY);
if (level == null || level.isEmpty()) {
return DEFAULT_VALIDATION_LEVEL;