Class BanPropertyPrefix

All Implemented Interfaces:
EnforcerRuleBase

@Named("banPropertyPrefix") public final class BanPropertyPrefix extends AbstractStandardEnforcerRule
This rule checks that no Maven property starts with any of the configured banned prefixes and fails the build if one or more offending properties are found. Each prefix entry may also contain several prefixes separated by commas. This is useful to forbid properties that are reserved for other tooling or no longer supported.
Since:
3.7.0
See Also:
  • Field Details

    • PREFIX_SEPARATOR

      private static final String PREFIX_SEPARATOR
      See Also:
    • MESSAGE_SEPARATOR

      private static final String MESSAGE_SEPARATOR
      See Also:
    • prefixes

      private List<String> prefixes
      List of prefixes that identify banned properties. Any project property whose name starts with one of these prefixes makes the rule fail. Each entry may also contain several prefixes separated by commas.
    • project

      private final org.apache.maven.project.MavenProject project
  • Constructor Details

    • BanPropertyPrefix

      @Inject public BanPropertyPrefix(org.apache.maven.project.MavenProject project)
  • Method Details

    • setPrefixes

      public void setPrefixes(List<String> prefixes)
    • getPrefixes

      public List<String> getPrefixes()
    • 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.
      Specified by:
      execute in class AbstractEnforcerRule
      Throws:
      EnforcerRuleException - the enforcer rule exception
    • normalizePrefixes

      static Set<String> normalizePrefixes(List<String> prefixes)
    • toString

      public String toString()
      Overrides:
      toString in class Object