The duplicate finder plugin allows global exclusion of dependencies, classes and resources. Any matching dependency or resource will not be considered duplicate, no matter how often it appears on the classpath.
This feature is very easy to abuse. Please use with care.
<configuration>
<useDefaultResourceIgnoreList>true</useDefaultResourceIgnoreList>
<ignoredClassPatterns>
<ignoredClassPattern>...</ignoredClassPattern>
</ignoredClassPatterns>
<ignoredResourcePatterns>
<ignoredResourcePattern>...</ignoredResourcePattern>
</ignoredResourcePatterns>
<ignoredDependencies>
<dependency>
<artifactId>...</artifactId>
<groupId>...</groupId>
<version>...</version>
<type>...</type>
<classifier>...</classifier>
</dependency>
</ignoredDependencies>
</configuration>
useDefaultResourceIgnoreList
flag
By default, the duplicate finder plugin ignores a set of resources on the classpath which tend to be duplicates all the time.
These resources are specified as standard Java regular expressions. All patterns are case insensitive.
The default resource ignore list is documented here.
Maven command line property: duplicate-finder.useDefaultResourceIgnoreList
(Plugin version 1.1.1+)
Default: true
Warning! Setting this element to false
will result in a significant number of false positives.
useDefaultClassIgnoreList
flag
Available in plugin version 1.2.1 and later.
By default, the duplicate finder plugin ignores a set of classes on the classpath which tend to be duplicates all the time.
These resources are specified as standard Java regular expressions. All patterns are case insensitive.
The default class ignore list is documented here.
Maven command line property: duplicate-finder.useDefaultClassIgnoreList
Default: true
ignoredResourcePatterns
for global resource exclusion
The ignoredResourcePatterns
element lists standard Java regular expression patterns that are excluded from the duplicate check. All patterns are treated as case insensitive.
Any pattern added here is treated similar to the patterns on the default resource ignore list.
Note. Any pattern here is applied to the whole resource path, not
to sub-components. It is therefore important to anchor a pattern to
the beginning, the end or a separator (/
). It is recommended to
test any regular expression with a
regular expression tester.
Examples
Ignore all resources ending in index.html
:
<configuration>
<ignoredResourcePatterns>
<ignoredResourcePattern>.*index\.html$</ignoredResourcePattern>
</ignoredResourcePatterns>
</configuration>
Ignore all log4j and logback configuration resources:
<configuration>
<ignoredResourcePatterns>
<ignoredResourcePattern>/?[^/]*?log4j\.xml$</ignoredResourcePattern>
<ignoredResourcePattern>/?[^/]*?log4j\.properties$</ignoredResourcePattern>
<ignoredResourcePattern>/?[^/]*?logback\.xml$</ignoredResourcePattern>
<ignoredResourcePattern>/?[^/]*?logback\.properties$</ignoredResourcePattern>
</ignoredResourcePatterns>
</configuration>
ignoredClassPatterns
for global resource exclusion
Available in plugin version 1.2.1 and later.
The ignoredClassPatterns
element lists standard Java regular expression patterns that are excluded from the duplicate check. All patterns are treated as case insensitive.
Any pattern added here is treated similar to the patterns on the default resource ignore list.
Note. Any pattern here is applied to the whole resource path, not
to sub-components. It is therefore important to anchor a pattern to
the beginning, the end or a separator (/
). It is recommended to
test any regular expression with a
regular expression tester.
Examples
Ignore all resources starting with javax
:
<configuration>
<ignoredClassPatterns>
<ignoredClassPattern>javax.*$</ignoredClassPattern>
</ignoredClassPatterns>
</configuration>
Ignore all classes that aren't from my company:
<configuration>
<ignoredClassPatterns>
<ignoredClassPattern>^((?!com[/.]mycompany).*)$</ignoredClassPattern>
</ignoredClassPatterns>
</configuration>
ignoredDependencies
for global dependency exclusion
Sometimes, a dependency is hopeless. It may drag in a large number of
duplicates or it may not have been written to any given standard. For
these very rare cases, it is possible to completely exclude a
dependency and everything that is related to it from the duplication
check. Usually, these dependencies are also in a non-standard scope
(such as provided
or system
).
Warning! Excluding a dependency globally may make the duplicate
finder check pass. It will not, however, fix the underlying cause
for the failure. Ignoring duplicate dependencies can and almost
always will lead to hard-to-debug runtime problems such as
hard-to-explain
ClassNotFoundException
(or their big sibling
NoClassDefFoundError
)
problems.
The ignoredDependencies
section contains [dependency
](Describing
Dependencies) elements. Each dependency
can be fully or partially
defined.
Each element listed here will be removed from the list of dependencies that are checked for duplicates.
Example
Remove org.jruby:jruby-complete
from the duplicate check:
<!-- jRuby is hopeless -->
<configuration>
<ignoredDependencies>
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby-complete</artifactId>
</dependency>
</ignoredDependencies>
</configuration>