Class BanDuplicateClasses
java.lang.Object
org.apache.maven.enforcer.rule.api.AbstractEnforcerRule
org.codehaus.mojo.extraenforcer.dependencies.AbstractResolveDependencies
org.codehaus.mojo.extraenforcer.dependencies.BanDuplicateClasses
- All Implemented Interfaces:
org.apache.maven.enforcer.rule.api.EnforcerRuleBase
Bans duplicate classes on the classpath.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.codehaus.mojo.extraenforcer.dependencies.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.class
will be duplicated in any jar file.private List
<Dependency> List of dependencies for which you want to ignore specific classes.private boolean
Iffalse
then the rule will fail at the first duplicate, iftrue
then the rule will fail at the end.private String[]
List of classes to ignore.private boolean
Iftrue
do not fail the build when duplicate classes exactly match each other.private String
The failure message -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
BanDuplicateClasses
(org.apache.maven.execution.MavenSession session, org.eclipse.aether.RepositorySystem repositorySystem) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
checkAndAddName
(org.apache.maven.artifact.Artifact artifact, String pathToClassFile, InputStreamSupplier inputStreamSupplier, Map<String, ClassesWithSameName> classesSeen, Set<String> duplicateClasses, Collection<AbstractResolveDependencies.IgnorableDependency> ignores) org.apache.maven.enforcer.rule.api.EnforcerLogger
getLog()
protected void
handleArtifacts
(Set<org.apache.maven.artifact.Artifact> artifacts) void
setLog
(org.apache.maven.enforcer.rule.api.EnforcerLogger arg0) Methods inherited from class org.codehaus.mojo.extraenforcer.dependencies.AbstractResolveDependencies
asRegex, execute
Methods inherited from class org.apache.maven.enforcer.rule.api.AbstractEnforcerRule
getCacheId, getLevel
-
Field Details
-
DEFAULT_CLASSES_IGNORES
Default ignores which are needed for JDK 9, cause in JDK 9 and above themodule-info.class
will be duplicated in any jar file. Furthermore in use cases for multi release jars themodule-info.class
is also contained several times. -
message
The failure message -
ignoreClasses
List of classes to ignore. Wildcard at the end accepted -
findAllDuplicates
private boolean findAllDuplicatesIffalse
then the rule will fail at the first duplicate, iftrue
then the rule will fail at the end. -
dependencies
List of dependencies for which you want to ignore specific classes. -
ignoreWhenIdentical
private boolean ignoreWhenIdenticalIftrue
do 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
@Inject protected BanDuplicateClasses(org.apache.maven.execution.MavenSession session, org.eclipse.aether.RepositorySystem repositorySystem)
-
-
Method Details
-
handleArtifacts
protected void handleArtifacts(Set<org.apache.maven.artifact.Artifact> artifacts) throws org.apache.maven.enforcer.rule.api.EnforcerRuleException - Specified by:
handleArtifacts
in classAbstractResolveDependencies
- Throws:
org.apache.maven.enforcer.rule.api.EnforcerRuleException
-
checkAndAddName
private void checkAndAddName(org.apache.maven.artifact.Artifact artifact, String pathToClassFile, InputStreamSupplier inputStreamSupplier, Map<String, ClassesWithSameName> classesSeen, Set<String> duplicateClasses, Collection<AbstractResolveDependencies.IgnorableDependency> ignores) throws org.apache.maven.enforcer.rule.api.EnforcerRuleException, IOException- Throws:
org.apache.maven.enforcer.rule.api.EnforcerRuleException
IOException
-
setLog
public void setLog(org.apache.maven.enforcer.rule.api.EnforcerLogger arg0) - Specified by:
setLog
in interfaceorg.apache.maven.enforcer.rule.api.EnforcerRuleBase
-
getLog
public org.apache.maven.enforcer.rule.api.EnforcerLogger getLog()
-