Class RequireNoRepositories

All Implemented Interfaces:
EnforcerRuleBase

@Named("requireNoRepositories") public final class RequireNoRepositories extends AbstractStandardEnforcerRule
This rule checks that this pom or its parents don't define a repository.
  • Field Details

    • VERSION

      private static final String VERSION
      See Also:
    • 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.
      See Also:
    • session

      private final org.apache.maven.execution.MavenSession session
  • Constructor Details

    • RequireNoRepositories

      @Inject public RequireNoRepositories(org.apache.maven.execution.MavenSession session)
  • Method Details

    • setBanRepositories

      public void setBanRepositories(boolean banRepositories)
    • setBanPluginRepositories

      public void setBanPluginRepositories(boolean banPluginRepositories)
    • setAllowedRepositories

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

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

      public void setAllowSnapshotRepositories(boolean allowSnapshotRepositories)
    • setAllowSnapshotPluginRepositories

      public void setAllowSnapshotPluginRepositories(boolean allowSnapshotPluginRepositories)
    • 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
    • getRepoIdsFromSettings

      private Collection<String> getRepoIdsFromSettings(Function<org.apache.maven.settings.Profile,List<org.apache.maven.settings.Repository>> getRepositoriesFunc)
    • 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.
    • toString

      public String toString()
      Overrides:
      toString in class Object