8000 [MNG-7823] Improve plugin validation level parsing (#1182) · apache/maven@9581129 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9581129

Browse files
authored
[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
1 parent b050257 commit 9581129

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginValidationManager.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,22 @@ private enum ValidationReportLevel {
8383
public void onEvent(Object event) {
8484
if (event instanceof ExecutionEvent) {
8585
ExecutionEvent executionEvent = (ExecutionEvent) event;
86-
if (executionEvent.getType() == ExecutionEvent.Type.SessionEnded) {
86+
if (executionEvent.getType() == ExecutionEvent.Type.SessionStarted) {
87+
RepositorySystemSession repositorySystemSession =
88+
executionEvent.getSession().getRepositorySession();
89+
validationReportLevel(repositorySystemSession); // this will parse and store it in session.data
90+
} else if (executionEvent.getType() == ExecutionEvent.Type.SessionEnded) {
8791
reportSessionCollectedValidationIssues(executionEvent.getSession());
8892
}
8993
}
9094
}
9195

9296
private ValidationReportLevel validationReportLevel(RepositorySystemSession session) {
97+
return (ValidationReportLevel) session.getData()
98+
.computeIfAbsent(ValidationReportLevel.class, () -> parseValidationReportLevel(session));
99+
}
100+
101+
private ValidationReportLevel parseValidationReportLevel(RepositorySystemSession session) {
93102
String level = ConfigUtils.getString(session, null, MAVEN_PLUGIN_VALIDATION_KEY);
94103
if (level == null || level.isEmpty()) {
95104
return DEFAULT_VALIDATION_LEVEL;

0 commit comments

Comments
 (0)
0