org.apache.maven.plugins.enforcer
Class BannedDependencies

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.AbstractBanDependencies
              extended by org.apache.maven.plugins.enforcer.BannedDependencies
Direct Known Subclasses:
BannedPlugins

public class BannedDependencies
extends AbstractBanDependencies

This rule checks that lists of dependencies are not included.

Version:
$Id: BannedDependencies.java 1345332 2012-06-01 20:14:13Z rfscholte $
Author:
Brian Fox

Field Summary
 List<String> excludes
          Specify the banned dependencies.
 List<String> includes
          Specify the allowed dependencies.
 
Fields inherited from class org.apache.maven.plugins.enforcer.AbstractStandardEnforcerRule
message
 
Constructor Summary
BannedDependencies()
           
 
Method Summary
protected  Set<Artifact> checkDependencies(Set<Artifact> theDependencies, Log log)
          Checks the set of dependencies against the list of excludes.
protected  boolean compareDependency(String[] pattern, Artifact artifact)
          Compares the parsed array of substrings against the artifact.
 List<String> getExcludes()
          Gets the excludes.
 List<String> getIncludes()
          Gets the includes.
 void setExcludes(List<String> theExcludes)
          Sets the excludes.
 void setIncludes(List<String> theIncludes)
          Sets the includes.
 
Methods inherited from class org.apache.maven.plugins.enforcer.AbstractBanDependencies
execute, getDependenciesToCheck, getErrorMessage, getMessage, isSearchTransitive, setMessage, setSearchTransitive
 
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

excludes

public List<String> excludes
Specify the banned dependencies. This can be a list of artifacts in the format groupId[:artifactId][:version]. Any of the sections can be a wildcard by using '*' (ie group:*:1.0)
The rule will fail if any dependency matches any exclude, unless it also matches an include rule.


includes

public List<String> includes
Specify the allowed dependencies. This can be a list of artifacts in the format groupId[:artifactId][:version]. Any of the sections can be a wildcard by using '*' (ie group:*:1.0)
Includes override the exclude rules. It is meant to allow wide exclusion rules with wildcards and still allow a smaller set of includes.
For example, to ban all xerces except xerces-api -> exclude "xerces", include "xerces:xerces-api"

Constructor Detail

BannedDependencies

public BannedDependencies()
Method Detail

checkDependencies

protected Set<Artifact> checkDependencies(Set<Artifact> theDependencies,
                                          Log log)
                                   throws EnforcerRuleException
Checks the set of dependencies against the list of excludes.

Specified by:
checkDependencies in class AbstractBanDependencies
Parameters:
theDependencies - the dependencies
log - the log
Returns:
the sets the
Throws:
EnforcerRuleException - the enforcer rule exception

compareDependency

protected boolean compareDependency(String[] pattern,
                                    Artifact artifact)
                             throws EnforcerRuleException
Compares the parsed array of substrings against the artifact. The pattern should follow the format "groupId:artifactId:version:type:scope"

Parameters:
pattern - the array of patterns
artifact - the artifact
Returns:
true if the artifact matches one of the patterns
Throws:
EnforcerRuleException - the enforcer rule exception

getExcludes

public List<String> getExcludes()
Gets the excludes.

Returns:
the excludes

setExcludes

public void setExcludes(List<String> theExcludes)
Sets the excludes.

Parameters:
theExcludes - the excludes to set

getIncludes

public List<String> getIncludes()
Gets the includes.

Returns:
the includes

setIncludes

public void setIncludes(List<String> theIncludes)
Sets the includes.

Parameters:
theIncludes - the includes to set


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