Package org.apache.maven.enforcer.rules
Class RequireNoRepositories
- java.lang.Object
-
- org.apache.maven.enforcer.rule.api.AbstractEnforcerRuleBase
-
- org.apache.maven.enforcer.rule.api.AbstractEnforcerRule
-
- org.apache.maven.enforcer.rules.AbstractStandardEnforcerRule
-
- org.apache.maven.enforcer.rules.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 Summary
Fields Modifier and Type Field Description private java.util.List<java.lang.String>
allowedPluginRepositories
Specify explicitly allowed plugin repositories.private java.util.List<java.lang.String>
allowedRepositories
Specify explicitly allowed non-plugin repositories.private boolean
allowSnapshotPluginRepositories
Whether to allow plugin repositories which only resolve snapshots.private boolean
allowSnapshotRepositories
Whether to allow repositories which only resolve snapshots.private boolean
banPluginRepositories
Whether to ban plugin repositories.private boolean
banRepositories
Whether to ban non-plugin repositories.private org.apache.maven.execution.MavenSession
session
private static java.lang.String
VERSION
-
Constructor Summary
Constructors Constructor Description RequireNoRepositories(org.apache.maven.execution.MavenSession session)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute()
This is the interface into the rule.private static java.util.List<java.lang.String>
findBannedRepositories(java.util.List<org.apache.maven.model.Repository> repos, java.util.List<java.lang.String> allowedRepos, boolean allowSnapshots)
private java.util.Collection<java.lang.String>
getRepoIdsFromSettings(java.util.function.Function<org.apache.maven.settings.Profile,java.util.List<org.apache.maven.settings.Repository>> getRepositoriesFunc)
void
setAllowedPluginRepositories(java.util.List<java.lang.String> allowedPluginRepositories)
void
setAllowedRepositories(java.util.List<java.lang.String> allowedRepositories)
void
setAllowSnapshotPluginRepositories(boolean allowSnapshotPluginRepositories)
void
setAllowSnapshotRepositories(boolean allowSnapshotRepositories)
void
setBanPluginRepositories(boolean banPluginRepositories)
void
setBanRepositories(boolean banRepositories)
java.lang.String
toString()
-
Methods inherited from class org.apache.maven.enforcer.rules.AbstractStandardEnforcerRule
formatLocation, getMessage, setMessage
-
Methods inherited from class org.apache.maven.enforcer.rule.api.AbstractEnforcerRule
getCacheId, getLevel, getRuleName
-
Methods inherited from class org.apache.maven.enforcer.rule.api.AbstractEnforcerRuleBase
getLog, setLog
-
-
-
-
Field Detail
-
VERSION
private static final java.lang.String VERSION
- See Also:
- Constant Field Values
-
banRepositories
private boolean banRepositories
Whether to ban non-plugin repositories. By default they are banned.- See Also:
setBanRepositories(boolean)
-
banPluginRepositories
private boolean banPluginRepositories
Whether to ban plugin repositories. By default they are banned.- See Also:
setBanPluginRepositories(boolean)
-
allowedRepositories
private java.util.List<java.lang.String> allowedRepositories
Specify explicitly allowed non-plugin repositories. This is a list of ids.- See Also:
setAllowedRepositories(List)
-
allowedPluginRepositories
private java.util.List<java.lang.String> allowedPluginRepositories
Specify explicitly allowed plugin repositories. This is a list of ids.- See Also:
setAllowedPluginRepositories(List)
-
allowSnapshotRepositories
private boolean allowSnapshotRepositories
Whether to allow repositories which only resolve snapshots. By default they are banned.- See Also:
setAllowSnapshotRepositories(boolean)
-
allowSnapshotPluginRepositories
private boolean allowSnapshotPluginRepositories
Whether to allow plugin repositories which only resolve snapshots. By default they are banned.
-
session
private final org.apache.maven.execution.MavenSession session
-
-
Method Detail
-
setBanRepositories
public void setBanRepositories(boolean banRepositories)
-
setBanPluginRepositories
public void setBanPluginRepositories(boolean banPluginRepositories)
-
setAllowedRepositories
public void setAllowedRepositories(java.util.List<java.lang.String> allowedRepositories)
-
setAllowedPluginRepositories
public void setAllowedPluginRepositories(java.util.List<java.lang.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 classAbstractEnforcerRule
- Throws:
EnforcerRuleException
- the enforcer rule exceptionEnforcerRuleError
- in order to brake a build immediately
-
getRepoIdsFromSettings
private java.util.Collection<java.lang.String> getRepoIdsFromSettings(java.util.function.Function<org.apache.maven.settings.Profile,java.util.List<org.apache.maven.settings.Repository>> getRepositoriesFunc)
-
findBannedRepositories
private static java.util.List<java.lang.String> findBannedRepositories(java.util.List<org.apache.maven.model.Repository> repos, java.util.List<java.lang.String> allowedRepos, boolean allowSnapshots)
- Parameters:
repos
- all repositories, nevernull
allowedRepos
- allowed repositories, nevernull
allowSnapshots
-- Returns:
- List of banned repositoreis.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-