mirror of https://github.com/apache/maven.git
[MNG-7767] Tone down plugin validator (#1092)
This change reduces default output making it more compact, and also renames the "levels" to brief, default and verbose. --- https://issues.apache.org/jira/browse/MNG-7767
This commit is contained in:
parent
81231b8865
commit
8b8f2c3ddd
|
@ -52,8 +52,8 @@ public final class DefaultPluginValidationManager extends AbstractMavenLifecycle
|
|||
private static final String MAVEN_PLUGIN_VALIDATION_KEY = "maven.plugin.validation";
|
||||
|
||||
private enum ValidationLevel {
|
||||
DISABLED,
|
||||
ENABLED,
|
||||
BRIEF,
|
||||
DEFAULT,
|
||||
VERBOSE
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ public final class DefaultPluginValidationManager extends AbstractMavenLifecycle
|
|||
private ValidationLevel validationLevel(RepositorySystemSession session) {
|
||||
String level = ConfigUtils.getString(session, null, MAVEN_PLUGIN_VALIDATION_KEY);
|
||||
if (level == null || level.isEmpty()) {
|
||||
return ValidationLevel.ENABLED;
|
||||
return ValidationLevel.DEFAULT;
|
||||
}
|
||||
try {
|
||||
return ValidationLevel.valueOf(level.toUpperCase(Locale.ENGLISH));
|
||||
|
@ -77,7 +77,7 @@ public final class DefaultPluginValidationManager extends AbstractMavenLifecycle
|
|||
MAVEN_PLUGIN_VALIDATION_KEY,
|
||||
level,
|
||||
Arrays.toString(ValidationLevel.values()));
|
||||
return ValidationLevel.ENABLED;
|
||||
return ValidationLevel.DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,6 +125,9 @@ public final class DefaultPluginValidationManager extends AbstractMavenLifecycle
|
|||
}
|
||||
|
||||
private void reportSessionCollectedValidationIssues(MavenSession mavenSession) {
|
||||
if (!logger.isWarnEnabled()) {
|
||||
return; // nothing can be reported
|
||||
}
|
||||
ValidationLevel validationLevel = validationLevel(mavenSession.getRepositorySession());
|
||||
ConcurrentHashMap<String, PluginValidationIssues> issuesMap = pluginIssues(mavenSession.getRepositorySession());
|
||||
if (!issuesMap.isEmpty()) {
|
||||
|
@ -132,46 +135,49 @@ public final class DefaultPluginValidationManager extends AbstractMavenLifecycle
|
|||
logger.warn("");
|
||||
logger.warn("Plugin validation issues were detected in {} plugin(s)", issuesMap.size());
|
||||
logger.warn("");
|
||||
if (validationLevel == ValidationLevel.DISABLED || !logger.isWarnEnabled()) {
|
||||
if (validationLevel == ValidationLevel.BRIEF) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Map.Entry<String, PluginValidationIssues> entry : issuesMap.entrySet()) {
|
||||
logger.warn("Plugin {}", entry.getKey());
|
||||
PluginValidationIssues issues = entry.getValue();
|
||||
if (validationLevel == ValidationLevel.VERBOSE && !issues.pluginDeclarations.isEmpty()) {
|
||||
logger.warn(" Declared at location(s):");
|
||||
for (String pluginDeclaration : issues.pluginDeclarations) {
|
||||
logger.warn(" * {}", pluginDeclaration);
|
||||
}
|
||||
}
|
||||
if (validationLevel == ValidationLevel.VERBOSE && !issues.pluginOccurrences.isEmpty()) {
|
||||
logger.warn(" Used in module(s):");
|
||||
for (String pluginOccurrence : issues.pluginOccurrences) {
|
||||
logger.warn(" * {}", pluginOccurrence);
|
||||
}
|
||||
}
|
||||
if (!issues.pluginIssues.isEmpty()) {
|
||||
logger.warn(" Plugin issue(s):");
|
||||
for (String pluginIssue : issues.pluginIssues) {
|
||||
logger.warn(" * {}", pluginIssue);
|
||||
}
|
||||
}
|
||||
if (!issues.mojoIssues.isEmpty()) {
|
||||
logger.warn(" Mojo issue(s):");
|
||||
for (String mojoInfo : issues.mojoIssues.keySet()) {
|
||||
logger.warn(" * Mojo {}", mojoInfo);
|
||||
for (String mojoIssue : issues.mojoIssues.get(mojoInfo)) {
|
||||
logger.warn(" - {}", mojoIssue);
|
||||
logger.warn(" * {}", entry.getKey());
|
||||
if (validationLevel == ValidationLevel.VERBOSE) {
|
||||
PluginValidationIssues issues = entry.getValue();
|
||||
if (!issues.pluginDeclarations.isEmpty()) {
|
||||
logger.warn(" Declared at location(s):");
|
||||
for (String pluginDeclaration : issues.pluginDeclarations) {
|
||||
logger.warn(" * {}", pluginDeclaration);
|
||||
}
|
||||
}
|
||||
if (!issues.pluginOccurrences.isEmpty()) {
|
||||
logger.warn(" Used in module(s):");
|
||||
for (String pluginOccurrence : issues.pluginOccurrences) {
|
||||
logger.warn(" * {}", pluginOccurrence);
|
||||
}
|
||||
}
|
||||
if (!issues.pluginIssues.isEmpty()) {
|
||||
logger.warn(" Plugin issue(s):");
|
||||
for (String pluginIssue : issues.pluginIssues) {
|
||||
logger.warn(" * {}", pluginIssue);
|
||||
}
|
||||
}
|
||||
if (!issues.mojoIssues.isEmpty()) {
|
||||
logger.warn(" Mojo issue(s):");
|
||||
for (String mojoInfo : issues.mojoIssues.keySet()) {
|
||||
logger.warn(" * Mojo {}", mojoInfo);
|
||||
for (String mojoIssue : issues.mojoIssues.get(mojoInfo)) {
|
||||
logger.warn(" - {}", mojoIssue);
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.warn("");
|
||||
}
|
||||
logger.warn("");
|
||||
}
|
||||
logger.warn("");
|
||||
logger.warn(
|
||||
"To fix these issues, please upgrade above listed plugins, or, notify their maintainers about reported issues.");
|
||||
logger.warn("");
|
||||
if (validationLevel == ValidationLevel.VERBOSE) {
|
||||
logger.warn(
|
||||
"Fix reported issues by adjusting plugin configuration or by upgrading above listed plugins. If no upgrade available, please notify plugin maintainers about reported issues.");
|
||||
}
|
||||
logger.warn(
|
||||
"For more or less details, use 'maven.plugin.validation' property with one of the values (case insensitive): {}",
|
||||
Arrays.toString(ValidationLevel.values()));
|
||||
|
|
Loading…
Reference in New Issue