slachiewicz commented on code in PR #11479:
URL: https://github.com/apache/maven/pull/11479#discussion_r2557508232
##########
maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java:
##########
@@ -279,22 +284,37 @@ public MojoDescriptor getMojoDescriptor(
return mojoDescriptor;
}
- public void checkRequiredMavenVersion(PluginDescriptor pluginDescriptor)
throws PluginIncompatibleException {
- String requiredMavenVersion =
pluginDescriptor.getRequiredMavenVersion();
- if (StringUtils.isNotBlank(requiredMavenVersion)) {
+ @Override
+ public void checkPrerequisites(PluginDescriptor pluginDescriptor) throws
PluginIncompatibleException {
+ List<IllegalStateException> prerequisiteExceptions = new ArrayList<>();
+ prerequisitesCheckers.forEach(c -> {
try {
- if (!runtimeInformation.isMavenVersion(requiredMavenVersion)) {
- throw new PluginIncompatibleException(
- pluginDescriptor.getPlugin(),
- "The plugin " + pluginDescriptor.getId() + "
requires Maven version "
- + requiredMavenVersion);
- }
- } catch (RuntimeException e) {
- logger.warn("Could not verify plugin's Maven prerequisite: " +
e.getMessage());
+ c.accept(pluginDescriptor);
+ } catch (IllegalStateException e) {
+ prerequisiteExceptions.add(e);
}
+ });
+ // aggregate all exceptions
+ if (!prerequisiteExceptions.isEmpty()) {
+ String messages = prerequisiteExceptions.stream()
+ .map(IllegalStateException::getMessage)
+ .collect(Collectors.joining(", "));
+ PluginIncompatibleException pie = new PluginIncompatibleException(
+ pluginDescriptor.getPlugin(),
+ "The plugin " + pluginDescriptor.getId() + " has unmet
prerequisites: " + messages,
+ prerequisiteExceptions.get(0));
+ // the first exception is added as cause, all other ones as
suppressed exceptions
+
prerequisiteExceptions.stream().skip(1).forEach(pie::addSuppressed);
+ throw pie;
}
}
+ @Override
+ @Deprecated
Review Comment:
Please add info what now is recommended
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]