Class BanDuplicateClasses
java.lang.Object
org.apache.maven.plugins.enforcer.AbstractMojoHausEnforcerRule
org.apache.maven.plugins.enforcer.AbstractResolveDependencies
org.apache.maven.plugins.enforcer.BanDuplicateClasses
- All Implemented Interfaces:
org.apache.maven.enforcer.rule.api.EnforcerRule,org.apache.maven.enforcer.rule.api.EnforcerRule2
Bans duplicate classes on the classpath.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.maven.plugins.enforcer.AbstractResolveDependencies
AbstractResolveDependencies.IgnorableDependency -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String[]Default ignores which are needed for JDK 9, cause in JDK 9 and above themodule-info.classwill be duplicated in any jar file.private List<Dependency>List of dependencies for which you want to ignore specific classes.private booleanIffalsethen the rule will fail at the first duplicate, iftruethen the rule will fail at the end.private String[]List of classes to ignore.private booleanIftruedo not fail the build when duplicate classes exactly match each other.private StringThe failure messageOnly verify dependencies with one of these scopes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcheckAndAddName(org.apache.maven.artifact.Artifact artifact, String pathToClassFile, Map<String, ClassesWithSameName> classesSeen, Set<String> duplicateClasses, Collection<AbstractResolveDependencies.IgnorableDependency> ignores) protected voidhandleArtifacts(Set<org.apache.maven.artifact.Artifact> artifacts) Methods inherited from class org.apache.maven.plugins.enforcer.AbstractResolveDependencies
asRegex, execute, getCacheId, getLog, isCacheable, isResultValid, isSearchTransitiveMethods inherited from class org.apache.maven.plugins.enforcer.AbstractMojoHausEnforcerRule
getLevel, setLevel
-
Field Details
-
DEFAULT_CLASSES_IGNORES
Default ignores which are needed for JDK 9, cause in JDK 9 and above themodule-info.classwill be duplicated in any jar file. Furthermore in use cases for multi release jars themodule-info.classis also contained several times. -
message
The failure message -
ignoreClasses
List of classes to ignore. Wildcard at the end accepted -
findAllDuplicates
private boolean findAllDuplicatesIffalsethen the rule will fail at the first duplicate, iftruethen the rule will fail at the end. -
dependencies
List of dependencies for which you want to ignore specific classes. -
scopes
Only verify dependencies with one of these scopes -
ignoreWhenIdentical
private boolean ignoreWhenIdenticalIftruedo not fail the build when duplicate classes exactly match each other. In other words, ignore duplication if the bytecode in the class files match. Default isfalse.
-
-
Constructor Details
-
BanDuplicateClasses
public BanDuplicateClasses()
-
-
Method Details
-
handleArtifacts
protected void handleArtifacts(Set<org.apache.maven.artifact.Artifact> artifacts) throws org.apache.maven.enforcer.rule.api.EnforcerRuleException - Specified by:
handleArtifactsin classAbstractResolveDependencies- Throws:
org.apache.maven.enforcer.rule.api.EnforcerRuleException
-
checkAndAddName
private void checkAndAddName(org.apache.maven.artifact.Artifact artifact, String pathToClassFile, Map<String, ClassesWithSameName> classesSeen, Set<String> duplicateClasses, Collection<AbstractResolveDependencies.IgnorableDependency> ignores) throws org.apache.maven.enforcer.rule.api.EnforcerRuleException- Throws:
org.apache.maven.enforcer.rule.api.EnforcerRuleException
-