Class RequirePluginVersions

All Implemented Interfaces:
EnforcerRuleBase

@Named("requirePluginVersions") public final class RequirePluginVersions extends AbstractStandardEnforcerRule
This rule will enforce that all plugins specified in the poms have a version declared.
Author:
Brian Fox
  • Constructor Details

    • RequirePluginVersions

      @Inject public RequirePluginVersions(org.apache.maven.plugin.PluginManager pluginManager, org.apache.maven.artifact.factory.ArtifactFactory factory, org.eclipse.aether.RepositorySystem repositorySystem, org.apache.maven.execution.MavenSession session, EnforcerRuleUtils utils, org.apache.maven.rtinfo.RuntimeInformation runtimeInformation, org.apache.maven.lifecycle.DefaultLifecycles defaultLifeCycles, org.apache.maven.project.MavenProject project, ExpressionEvaluator evaluator, org.codehaus.plexus.PlexusContainer container)
  • Method Details

    • execute

      public void execute() throws EnforcerRuleException
      Description copied from class: AbstractEnforcerRule
      This is the interface into the rule. This method should throw an exception containing a reason message if the rule fails the check. The plugin will then decide based on the fail flag and rule level if it should stop or just log the message as a warning.
      Specified by:
      execute in class AbstractEnforcerRule
      Throws:
      EnforcerRuleException - the enforcer rule exception
      EnforcerRuleError - in order to brake a build immediately
    • combineUncheckedPlugins

      public Collection<String> combineUncheckedPlugins(Collection<String> uncheckedPlugins, String uncheckedPluginsList)
      Combines the old Collection with the new comma separated list.
      Parameters:
      uncheckedPlugins - a new collections
      uncheckedPluginsList - a list to merge
      Returns:
      List of unchecked plugins.
    • addAdditionalPlugins

      public Set<org.apache.maven.model.Plugin> addAdditionalPlugins(Set<org.apache.maven.model.Plugin> existing, List<String> additional) throws EnforcerRuleError
      Add the additional plugins if they don't exist yet.
      Parameters:
      existing - the existing
      additional - the additional
      Returns:
      the sets the
      Throws:
      EnforcerRuleError - the enforcer error
    • getProfilePlugins

      public Set<org.apache.maven.model.Plugin> getProfilePlugins(org.apache.maven.project.MavenProject project)
      Finds the plugins that are listed in active profiles.
      Parameters:
      project - the project
      Returns:
      the profile plugins
    • hasValidVersionSpecified

      public boolean hasValidVersionSpecified(org.apache.maven.model.Plugin source, List<PluginWrapper> pluginWrappers)
      Checks for valid version specified. Checks to see if the version is specified for the plugin. Can optionally ban "RELEASE" or "LATEST" even if specified.
      Parameters:
      source - the source
      pluginWrappers - the plugins
      Returns:
      true, if successful
    • getPhaseToLifecycleMap

      public Map<String,org.apache.maven.lifecycle.Lifecycle> getPhaseToLifecycleMap() throws org.apache.maven.lifecycle.LifecycleExecutionException
      Gets the phase to lifecycle map.
      Returns:
      the phase to lifecycle map
      Throws:
      org.apache.maven.lifecycle.LifecycleExecutionException - the lifecycle execution exception
    • setBanLatest

      public void setBanLatest(boolean theBanLatest)
      Sets the ban latest.
      Parameters:
      theBanLatest - the banLatest to set
    • setBanRelease

      public void setBanRelease(boolean theBanRelease)
      Sets the ban release.
      Parameters:
      theBanRelease - the banRelease to set
    • isBanSnapshots

      public boolean isBanSnapshots()
      Checks if is ban snapshots.
      Returns:
      the banSnapshots
    • setBanSnapshots

      public void setBanSnapshots(boolean theBanSnapshots)
      Sets the ban snapshots.
      Parameters:
      theBanSnapshots - the banSnapshots to set
    • setBanTimestamps

      public void setBanTimestamps(boolean theBanTimestamps)
      Sets the ban timestamps.
      Parameters:
      theBanTimestamps - the banTimestamps to set
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setLog

      public void setLog(EnforcerLogger log)
      Used by EnforcerMojo to inject logger instance
      Specified by:
      setLog in interface EnforcerRuleBase
      Parameters:
      log - an EnforcerLogger instance
    • getLog

      public EnforcerLogger getLog()
      Provide an EnforcerLogger instance for Rule

      NOTICE A logger is not available in constructors.

      Returns:
      an EnforcerLogger instance