Class RequireNoRepositories

All Implemented Interfaces:
EnforcerRule, EnforcerRule2

public class RequireNoRepositories extends AbstractNonCacheableEnforcerRule
This rule checks that this pom or its parents don't define a repository.
  • Field Details

    • banRepositories

      private boolean banRepositories
      Whether to ban non-plugin repositories. By default they are banned.
      See Also:
    • banPluginRepositories

      private boolean banPluginRepositories
      Whether to ban plugin repositories. By default they are banned.
      See Also:
    • allowedRepositories

      private List<String> allowedRepositories
      Specify explicitly allowed non-plugin repositories. This is a list of ids.
      See Also:
    • allowedPluginRepositories

      private List<String> allowedPluginRepositories
      Specify explicitly allowed plugin repositories. This is a list of ids.
      See Also:
    • allowSnapshotRepositories

      private boolean allowSnapshotRepositories
      Whether to allow repositories which only resolve snapshots. By default they are banned.
      See Also:
    • allowSnapshotPluginRepositories

      private boolean allowSnapshotPluginRepositories
      Whether to allow plugin repositories which only resolve snapshots. By default they are banned.
  • Constructor Details

    • RequireNoRepositories

      public RequireNoRepositories()
  • Method Details

    • setBanRepositories

      public final void setBanRepositories(boolean banRepositories)
    • setBanPluginRepositories

      public final void setBanPluginRepositories(boolean banPluginRepositories)
    • setAllowedRepositories

      public final void setAllowedRepositories(List<String> allowedRepositories)
    • setAllowedPluginRepositories

      public final void setAllowedPluginRepositories(List<String> allowedPluginRepositories)
    • setAllowSnapshotRepositories

      public final void setAllowSnapshotRepositories(boolean allowSnapshotRepositories)
    • setAllowSnapshotPluginRepositories

      public final void setAllowSnapshotPluginRepositories(boolean allowSnapshotPluginRepositories)
    • execute

      public void execute(EnforcerRuleHelper helper) throws EnforcerRuleException
      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:
      helper - 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
    • findBannedRepositories

      private static List<String> findBannedRepositories(List<org.apache.maven.model.Repository> repos, List<String> allowedRepos, boolean allowSnapshots)
      Parameters:
      repos - all repositories, never null
      allowedRepos - allowed repositories, never null
      allowSnapshots -
      Returns:
      List of banned repositoreis.