Class RequireActiveProfile

All Implemented Interfaces:
EnforcerRule, EnforcerRule2

public class RequireActiveProfile extends AbstractNonCacheableEnforcerRule
This rule checks that some profiles are active.
  • Field Details

    • profiles

      private String profiles
      Comma separated list of profiles to check.
    • all

      private boolean all
      If all profiles must be active. If false, only one must be active
  • Constructor Details

    • RequireActiveProfile

      public RequireActiveProfile()
  • Method Details

    • getProfiles

      public final String getProfiles()
    • setProfiles

      public final void setProfiles(String profiles)
    • isAll

      public final boolean isAll()
    • setAll

      public final void setAll(boolean all)
    • execute

      public void execute(EnforcerRuleHelper theHelper) throws EnforcerRuleException
      Description copied from interface: EnforcerRule
      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 if it should stop or just log the message as a warning.
      Parameters:
      theHelper - The helper provides access to the log, MavenSession and has helpers to get common components. It is also able to lookup components by class name.
      Throws:
      EnforcerRuleException - the enforcer rule exception
    • isProfileActive

      protected boolean isProfileActive(org.apache.maven.project.MavenProject project, String profileId)
      Checks if profile is active.
      Parameters:
      project - the project
      profileId - the profile name
      Returns:
      true if profile is active, otherwise false