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:
    MENFORCER-433
    • Field Detail

      • PREFIX_SEPARATOR

        private static final java.lang.String PREFIX_SEPARATOR
        See Also:
        Constant Field Values
      • MESSAGE_SEPARATOR

        private static final java.lang.String MESSAGE_SEPARATOR
        See Also:
        Constant Field Values
      • prefixes

        private java.util.List<java.lang.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 Detail

      • BanPropertyPrefix

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

      • setPrefixes

        public void setPrefixes​(java.util.List<java.lang.String> prefixes)
      • getPrefixes

        public java.util.List<java.lang.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
        EnforcerRuleError - in order to brake a build immediately
      • normalizePrefixes

        static java.util.Set<java.lang.String> normalizePrefixes​(java.util.List<java.lang.String> prefixes)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object