in enforcer-rules/src/main/java/org/apache/maven/enforcer/rules/RequirePluginVersions.java [197:246]
public void execute() throws EnforcerRuleException {
try {
// get the various expressions out of the helper.
lifecycles = defaultLifeCycles.getLifeCycles();
// get all the plugins that are bound to the specified lifecycles
Set<Plugin> allPlugins = getBoundPlugins(project, phases);
// insert any additional plugins specified by the user.
allPlugins = addAdditionalPlugins(allPlugins, additionalPlugins);
allPlugins.addAll(getProfilePlugins(project));
// pull out any we should skip
allPlugins =
removeUncheckedPlugins(combineUncheckedPlugins(unCheckedPlugins, unCheckedPluginList), allPlugins);
// there's nothing to do here
if (allPlugins.isEmpty()) {
getLog().info("No plugin bindings found.");
return;
} else {
getLog().debug("All Plugins in use: " + allPlugins);
}
// get all the plugins that are mentioned in the pom (and parents)
List<PluginWrapper> pluginWrappers = getAllPluginEntries(project);
for (PluginWrapper pluginWrapper : pluginWrappers) {
getLog().debug("pluginWrappers: " + pluginWrapper.getGroupId() + ":" + pluginWrapper.getArtifactId()
+ ":" + pluginWrapper.getVersion() + " source: " + pluginWrapper.getSource());
}
// now look for the versions that aren't valid and add to a list.
List<Plugin> failures = new ArrayList<>();
for (Plugin plugin : allPlugins) {
if (!hasValidVersionSpecified(plugin, pluginWrappers)) {
failures.add(plugin);
}
}
// if anything was found, log it then append the optional message.
if (!failures.isEmpty()) {
handleMessagesToTheUser(project, failures);
}
} catch (PluginNotFoundException | LifecycleExecutionException e) {
throw new EnforcerRuleException(e.getLocalizedMessage(), e);
}
}