Package org.apache.maven.enforcer.rules
Class RequireActiveProfile
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.RequireActiveProfile
- All Implemented Interfaces:
EnforcerRuleBase
@Named("requireActiveProfile")
public final class RequireActiveProfile
extends AbstractStandardEnforcerRule
This rule checks that some profiles are active.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute()
This is the interface into the rule.boolean
isAll()
private boolean
isProfileActive
(org.apache.maven.project.MavenProject project, String profileId) Checks if profile is active.void
setAll
(boolean all) void
setProfiles
(String profiles) toString()
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
-
Field Details
-
profiles
Comma separated list of profiles to check. -
all
private boolean allIf all profiles must be active. If false, only one must be active -
project
private final org.apache.maven.project.MavenProject project
-
-
Constructor Details
-
RequireActiveProfile
@Inject public RequireActiveProfile(org.apache.maven.project.MavenProject project)
-
-
Method Details
-
getProfiles
-
setProfiles
-
isAll
public boolean isAll() -
setAll
public void setAll(boolean all) -
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.- Specified by:
execute
in classAbstractEnforcerRule
- Throws:
EnforcerRuleException
- the enforcer rule exception
-
isProfileActive
Checks if profile is active.- Parameters:
project
- the projectprofileId
- the profile name- Returns:
true
if profile is active, otherwisefalse
-
toString
-