org.apache.maven.plugins.enforcer
Class RequirePluginVersions

java.lang.Object
  extended by org.apache.maven.plugins.enforcer.AbstractStandardEnforcerRule
      extended by org.apache.maven.plugins.enforcer.AbstractNonCacheableEnforcerRule
          extended by org.apache.maven.plugins.enforcer.RequirePluginVersions

public class RequirePluginVersions
extends AbstractNonCacheableEnforcerRule

This rule will enforce that all plugins specified in the poms have a version declared.

Version:
$Id: RequirePluginVersions.java 1357143 2012-07-04 08:00:43Z baerrach $
Author:
Brian Fox

Field Summary
 List<String> additionalPlugins
          Additional plugins to enforce have versions.
 boolean banLatest
          Don't allow the LATEST identifier.
 boolean banRelease
          Don't allow the RELEASE identifier.
 boolean banSnapshots
          Don't allow snapshot plugins.
 boolean banTimestamps
          Don't allow timestamp snapshot plugins.
 String phases
          The comma separated list of phases that should be used to find lifecycle plugin bindings.
 String unCheckedPluginList
          Same as unCheckedPlugins but as a comma list to better support properties.
 List unCheckedPlugins
          Deprecated.  
 
Fields inherited from class org.apache.maven.plugins.enforcer.AbstractStandardEnforcerRule
message
 
Constructor Summary
RequirePluginVersions()
           
 
Method Summary
 Set<org.apache.maven.model.Plugin> addAdditionalPlugins(Set<org.apache.maven.model.Plugin> existing, List<String> additional)
          Add the additional plugins if they don't exist yet.
 Collection<String> combineUncheckedPlugins(Collection<String> uncheckedPlugins, String uncheckedPluginsList)
          Combines the old Collection with the new comma separated list.
 void execute(EnforcerRuleHelper helper)
           
protected  org.apache.maven.model.Plugin findCurrentPlugin(org.apache.maven.model.Plugin plugin, MavenProject project)
          Given a plugin, this will retrieve the matching plugin artifact from the model.
protected  List<PluginWrapper> getAllPluginEntries(MavenProject project)
          Gets all plugin entries in build.plugins, build.pluginManagement.plugins, profile.build.plugins, reporting and profile.reporting in this project and all parents
protected  Set<org.apache.maven.model.Plugin> getBoundPlugins(LifecycleExecutor life, MavenProject project, String thePhases)
          Gets the plugins that are bound to the defined phases.
protected  String getMessage()
          Gets the message.
 Map<String,Lifecycle> getPhaseToLifecycleMap()
          Gets the phase to lifecycle map.
 Set<org.apache.maven.model.Plugin> getProfilePlugins(MavenProject project)
          Finds the plugins that are listed in active profiles.
 List getUnCheckedPlugins()
           
protected  EnforcerRuleUtils getUtils()
          Gets the utils.
protected  boolean hasValidVersionSpecified(EnforcerRuleHelper helper, org.apache.maven.model.Plugin source, List<PluginWrapper> pluginWrappers)
          Checks for valid version specified.
protected  boolean isBanLatest()
          Checks if is ban latest.
protected  boolean isBanRelease()
          Checks if is ban release.
 boolean isBanSnapshots()
          Checks if is ban snapshots.
 boolean isBanTimestamps()
          Checks if is ban timestamps.
protected  boolean isSnapshot(String baseVersion)
          Checks if is snapshot.
protected  org.apache.maven.model.Plugin parsePluginString(String pluginString, String field)
          Helper method to parse and inject a Plugin.
 Collection<org.apache.maven.model.Plugin> removeUncheckedPlugins(Collection<String> uncheckedPlugins, Collection<org.apache.maven.model.Plugin> plugins)
          Remove the plugins that the user doesn't want to check.
protected  org.apache.maven.model.Plugin resolvePlugin(org.apache.maven.model.Plugin plugin, MavenProject project)
          Resolve plugin.
protected  void setBanLatest(boolean theBanLatest)
          Sets the ban latest.
protected  void setBanRelease(boolean theBanRelease)
          Sets the ban release.
 void setBanSnapshots(boolean theBanSnapshots)
          Sets the ban snapshots.
 void setBanTimestamps(boolean theBanTimestamps)
          Sets the ban timestamps.
protected  void setMessage(String theMessage)
          Sets the message.
 void setUnCheckedPlugins(List unCheckedPlugins)
           
protected  void setUtils(EnforcerRuleUtils theUtils)
          Sets the utils.
 
Methods inherited from class org.apache.maven.plugins.enforcer.AbstractNonCacheableEnforcerRule
getCacheId, isCacheable, isResultValid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

banLatest

public boolean banLatest
Don't allow the LATEST identifier.


banRelease

public boolean banRelease
Don't allow the RELEASE identifier.


banSnapshots

public boolean banSnapshots
Don't allow snapshot plugins.


banTimestamps

public boolean banTimestamps
Don't allow timestamp snapshot plugins.


phases

public String phases
The comma separated list of phases that should be used to find lifecycle plugin bindings. The default value is "clean,deploy,site".


additionalPlugins

public List<String> additionalPlugins
Additional plugins to enforce have versions. These are plugins that may not be in the poms but are used anyway, like help, eclipse etc.
The plugins should be specified in the form: group:artifactId.


unCheckedPlugins

public List unCheckedPlugins
Deprecated. 
Plugins to skip for version enforcement. The plugins should be specified in the form: group:artifactId. NOTE: This is deprecated, use unCheckedPluginList instead.


unCheckedPluginList

public String unCheckedPluginList
Same as unCheckedPlugins but as a comma list to better support properties. Sample form: group:artifactId,group2:artifactId2

Since:
1.0-beta-1
Constructor Detail

RequirePluginVersions

public RequirePluginVersions()
Method Detail

execute

public void execute(EnforcerRuleHelper helper)
             throws EnforcerRuleException
Throws:
EnforcerRuleException

removeUncheckedPlugins

public Collection<org.apache.maven.model.Plugin> removeUncheckedPlugins(Collection<String> uncheckedPlugins,
                                                                        Collection<org.apache.maven.model.Plugin> plugins)
                                                                 throws MojoExecutionException
Remove the plugins that the user doesn't want to check.

Parameters:
uncheckedPlugins -
plugins -
Returns:
Throws:
MojoExecutionException

combineUncheckedPlugins

public Collection<String> combineUncheckedPlugins(Collection<String> uncheckedPlugins,
                                                  String uncheckedPluginsList)
Combines the old Collection with the new comma separated list.

Parameters:
uncheckedPlugins -
uncheckedPluginsList -
Returns:

addAdditionalPlugins

public Set<org.apache.maven.model.Plugin> addAdditionalPlugins(Set<org.apache.maven.model.Plugin> existing,
                                                               List<String> additional)
                                                        throws MojoExecutionException
Add the additional plugins if they don't exist yet.

Parameters:
existing - the existing
additional - the additional
Returns:
the sets the
Throws:
MojoExecutionException - the mojo execution exception

parsePluginString

protected org.apache.maven.model.Plugin parsePluginString(String pluginString,
                                                          String field)
                                                   throws MojoExecutionException
Helper method to parse and inject a Plugin.

Parameters:
pluginString -
Returns:
Throws:
MojoExecutionException

getProfilePlugins

public Set<org.apache.maven.model.Plugin> getProfilePlugins(MavenProject project)
Finds the plugins that are listed in active profiles.

Parameters:
project - the project
Returns:
the profile plugins

findCurrentPlugin

protected org.apache.maven.model.Plugin findCurrentPlugin(org.apache.maven.model.Plugin plugin,
                                                          MavenProject project)
Given a plugin, this will retrieve the matching plugin artifact from the model.

Parameters:
plugin - plugin to lookup
project - project to search
Returns:
matching plugin, null if not found.

resolvePlugin

protected org.apache.maven.model.Plugin resolvePlugin(org.apache.maven.model.Plugin plugin,
                                                      MavenProject project)
Resolve plugin.

Parameters:
plugin - the plugin
project - the project
Returns:
the plugin

getBoundPlugins

protected Set<org.apache.maven.model.Plugin> getBoundPlugins(LifecycleExecutor life,
                                                             MavenProject project,
                                                             String thePhases)
                                                      throws PluginNotFoundException,
                                                             LifecycleExecutionException,
                                                             IllegalAccessException
Gets the plugins that are bound to the defined phases. This does not find plugins bound in the pom to a phase later than the plugin is executing.

Parameters:
life - the life
project - the project
thePhases - the the phases
Returns:
the bound plugins
Throws:
PluginNotFoundException - the plugin not found exception
LifecycleExecutionException - the lifecycle execution exception
IllegalAccessException - the illegal access exception

hasValidVersionSpecified

protected boolean hasValidVersionSpecified(EnforcerRuleHelper helper,
                                           org.apache.maven.model.Plugin source,
                                           List<PluginWrapper> pluginWrappers)
Checks for valid version specified.

Parameters:
helper - the helper
source - the source
pluginWrappers - the plugins
Returns:
true, if successful

isSnapshot

protected boolean isSnapshot(String baseVersion)
Checks if is snapshot.

Parameters:
baseVersion - the base version
Returns:
true, if is snapshot

getPhaseToLifecycleMap

public Map<String,Lifecycle> getPhaseToLifecycleMap()
                                             throws LifecycleExecutionException
Gets the phase to lifecycle map.

Returns:
the phase to lifecycle map
Throws:
LifecycleExecutionException - the lifecycle execution exception

getAllPluginEntries

protected List<PluginWrapper> getAllPluginEntries(MavenProject project)
                                           throws ArtifactResolutionException,
                                                  ArtifactNotFoundException,
                                                  IOException,
                                                  XmlPullParserException
Gets all plugin entries in build.plugins, build.pluginManagement.plugins, profile.build.plugins, reporting and profile.reporting in this project and all parents

Parameters:
project - the project
Returns:
the all plugin entries wrapped in a PluginWrapper Object
Throws:
ArtifactResolutionException - the artifact resolution exception
ArtifactNotFoundException - the artifact not found exception
IOException - Signals that an I/O exception has occurred.
XmlPullParserException - the xml pull parser exception

isBanLatest

protected boolean isBanLatest()
Checks if is ban latest.

Returns:
the banLatest

setBanLatest

protected void setBanLatest(boolean theBanLatest)
Sets the ban latest.

Parameters:
theBanLatest - the banLatest to set

isBanRelease

protected boolean isBanRelease()
Checks if is ban release.

Returns:
the banRelease

setBanRelease

protected void setBanRelease(boolean theBanRelease)
Sets the ban release.

Parameters:
theBanRelease - the banRelease to set

getMessage

protected String getMessage()
Gets the message.

Returns:
the message

setMessage

protected void setMessage(String theMessage)
Sets the message.

Parameters:
theMessage - the message to set

getUtils

protected EnforcerRuleUtils getUtils()
Gets the utils.

Returns:
the utils

setUtils

protected void setUtils(EnforcerRuleUtils theUtils)
Sets the utils.

Parameters:
theUtils - the utils 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

isBanTimestamps

public boolean isBanTimestamps()
Checks if is ban timestamps.

Returns:
the banTimestamps

setBanTimestamps

public void setBanTimestamps(boolean theBanTimestamps)
Sets the ban timestamps.

Parameters:
theBanTimestamps - the banTimestamps to set

getUnCheckedPlugins

public List getUnCheckedPlugins()

setUnCheckedPlugins

public void setUnCheckedPlugins(List unCheckedPlugins)


Copyright © 2007-2012 The Apache Software Foundation. All Rights Reserved.