Skip to content

Commit

Permalink
[MNG-7823] Improve plugin validation level parsing (#1182)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cstamas authored Jun 23, 2023
1 parent b050257 commit 9581129
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,22 @@ private enum ValidationReportLevel {
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;
Expand Down

0 comments on commit 9581129

Please sign in to comment.