Class RequireReleaseDeps
- java.lang.Object
-
- org.apache.maven.enforcer.rule.api.AbstractEnforcerRuleBase
-
- org.apache.maven.enforcer.rule.api.AbstractEnforcerRule
-
- org.apache.maven.enforcer.rules.AbstractStandardEnforcerRule
-
- org.apache.maven.enforcer.rules.dependency.BannedDependenciesBase
-
- org.apache.maven.enforcer.rules.dependency.RequireReleaseDeps
-
- All Implemented Interfaces:
EnforcerRuleBase
@Named("requireReleaseDeps") public final class RequireReleaseDeps extends BannedDependenciesBase
This rule checks that no snapshots are included.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
failWhenParentIsSnapshot
Allows this rule to fail when the parent is defined as a snapshot.private boolean
onlyWhenRelease
Allows this rule to execute only when this project is a release.
-
Constructor Summary
Constructors Constructor Description RequireReleaseDeps(org.apache.maven.execution.MavenSession session, ResolverUtil resolverUtil)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute()
This is the interface into the rule.private java.util.Set<org.apache.maven.artifact.Artifact>
filterArtifacts(java.util.Set<org.apache.maven.artifact.Artifact> dependencies)
Filter the dependency artifacts according to the includes and excludes If includes and excludes are both null, the original set is returned.protected java.lang.String
getErrorMessage()
void
setFailWhenParentIsSnapshot(boolean failWhenParentIsSnapshot)
void
setOnlyWhenRelease(boolean onlyWhenRelease)
java.lang.String
toString()
protected boolean
validate(org.apache.maven.artifact.Artifact artifact)
Validates a dependency artifact if it fulfills the enforcer rule-
Methods inherited from class org.apache.maven.enforcer.rules.dependency.BannedDependenciesBase
getExcludes, getIncludes, getSession, isSearchTransitive, setExcludes, setIncludes, setSearchTransitive, validate
-
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
-
Methods inherited from class org.apache.maven.enforcer.rule.api.AbstractEnforcerRuleBase
getLog, setLog
-
-
-
-
Constructor Detail
-
RequireReleaseDeps
@Inject public RequireReleaseDeps(org.apache.maven.execution.MavenSession session, ResolverUtil resolverUtil)
-
-
Method Detail
-
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.- Overrides:
execute
in classBannedDependenciesBase
- Throws:
EnforcerRuleException
- the enforcer rule exceptionEnforcerRuleError
- in order to brake a build immediately
-
getErrorMessage
protected java.lang.String getErrorMessage()
- Specified by:
getErrorMessage
in classBannedDependenciesBase
-
validate
protected boolean validate(org.apache.maven.artifact.Artifact artifact)
Description copied from class:BannedDependenciesBase
Validates a dependency artifact if it fulfills the enforcer rule- Specified by:
validate
in classBannedDependenciesBase
- 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
-
filterArtifacts
private java.util.Set<org.apache.maven.artifact.Artifact> filterArtifacts(java.util.Set<org.apache.maven.artifact.Artifact> dependencies) throws EnforcerRuleException
Filter the dependency artifacts according to the includes and excludes If includes and excludes are both null, the original set is returned.- Parameters:
dependencies
- the list of dependencies to filter- Returns:
- the resulting set of dependencies
- Throws:
EnforcerRuleException
-
setOnlyWhenRelease
public void setOnlyWhenRelease(boolean onlyWhenRelease)
-
setFailWhenParentIsSnapshot
public void setFailWhenParentIsSnapshot(boolean failWhenParentIsSnapshot)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-