Class RequireReleaseDeps
java.lang.Object
org.apache.maven.enforcer.rule.api.AbstractEnforcerRule
org.apache.maven.enforcer.rules.AbstractStandardEnforcerRule
org.apache.maven.enforcer.rules.dependency.RequireReleaseDeps
- All Implemented Interfaces:
EnforcerRuleBase
@Named("requireReleaseDeps")
public final class RequireReleaseDeps
extends AbstractStandardEnforcerRule
This rule checks that no snapshots are included.
- Author:
- Brian Fox
-
Constructor Summary
ConstructorDescriptionRequireReleaseDeps
(org.apache.maven.execution.MavenSession session, org.apache.maven.enforcer.rules.dependency.ResolverUtil resolverUtil) -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute()
This is the interface into the rule.protected String
Gets the excludes.Gets the includes.getLog()
Provide anEnforcerLogger
instance for Ruleprotected org.apache.maven.execution.MavenSession
boolean
void
setExcludes
(List<String> theExcludes) Specify the banned dependencies.void
setFailWhenParentIsSnapshot
(boolean failWhenParentIsSnapshot) void
setIncludes
(List<String> theIncludes) Specify the allowed dependencies.void
setLog
(EnforcerLogger log) Used byEnforcerMojo
to inject logger instancevoid
setOnlyWhenRelease
(boolean onlyWhenRelease) void
setSearchTransitive
(boolean theSearchTransitive) Sets the search transitive.toString()
protected boolean
validate
(org.apache.maven.artifact.Artifact artifact) Validates a dependency artifact if it fulfills the enforcer ruleprotected boolean
validate
(org.eclipse.aether.graph.DependencyNode node, int level, StringBuilder messageBuilder) Methods inherited from class org.apache.maven.enforcer.rules.AbstractStandardEnforcerRule
formatLocation, getMessage, setMessage
Methods inherited from class org.apache.maven.enforcer.rule.api.AbstractEnforcerRule
getCacheId, getLevel
-
Constructor Details
-
RequireReleaseDeps
@Inject public RequireReleaseDeps(org.apache.maven.execution.MavenSession session, org.apache.maven.enforcer.rules.dependency.ResolverUtil resolverUtil)
-
-
Method Details
-
execute
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.- Throws:
EnforcerRuleException
- the enforcer rule exception
-
getErrorMessage
-
validate
Validates a dependency artifact if it fulfills the enforcer rule- Parameters:
artifact
- dependency to be checked against the list of excludes- Returns:
true
if the dependency passes the rule,false
if the dependency triggers a validation error
-
setOnlyWhenRelease
-
setFailWhenParentIsSnapshot
-
toString
-
getSession
protected org.apache.maven.execution.MavenSession getSession() -
validate
protected boolean validate(org.eclipse.aether.graph.DependencyNode node, int level, StringBuilder messageBuilder) -
setSearchTransitive
public void setSearchTransitive(boolean theSearchTransitive) Sets the search transitive.- Parameters:
theSearchTransitive
- the searchTransitive to set
-
getExcludes
Gets the excludes.- Returns:
- the excludes
-
setExcludes
Specify the banned dependencies. This can be a list of artifacts in the formatgroupId[: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.- Parameters:
theExcludes
- the excludes to set- See Also:
-
getIncludes
Gets the includes.- Returns:
- the includes
-
setIncludes
Specify the allowed dependencies. This can be a list of artifacts in the formatgroupId[: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"- Parameters:
theIncludes
- the includes to set- See Also:
-
isSearchTransitive
public boolean isSearchTransitive() -
setLog
Used byEnforcerMojo
to inject logger instance- Specified by:
setLog
in interfaceEnforcerRuleBase
- Parameters:
log
- anEnforcerLogger
instance
-
getLog
Provide anEnforcerLogger
instance for RuleNOTICE A logger is not available in constructors.
- Returns:
- an
EnforcerLogger
instance
-