-
Notifications
You must be signed in to change notification settings - Fork 34
Addressing dependency clash
John Bogovic edited this page Jun 28, 2019
·
2 revisions
The pom-scijava
bill of materials, in addition to declaring versions of components in the SciJava component collection, also adds necessary exclusions, so that you shouldn't have to. If you end up needing an exclusion, it's good to post on forum.image.sc about it to discuss whether we should add that exclusion to pom-scijava so that everyone benefits automatically, instead of stumbling over the same thing.
This example will describe how to use eclipse to find and address duplicate classes that appear in dependencies that maven finds.
- Import this maven project into eclipse
- Navigate to the folder containing the "pom.xml" file, and run
mvn
- Observe that you get the error below "No Duplicate Classes Allowed"
- Find the part of the error output telling us that it is the
regexp
andxalan
dependencies that have duplicate classes - Open the pom.xml in eclipse
- Open the "Dependency Hierarchy" tab.
- Type "xalan" into the Filter field near the top-right of the "Dependency Hierarchy" window, and see that we're depending on
xalan-2.7.1
- Right click
xalan-2.7.1
in the window, choose "Exclude maven artifact", and press "Ok" - Save the pom.xml
- Notice that the pom.xml changed - look at what it did. (
git diff
will show what the changes are) - Go back to the command line, run
mvn
and see that it works now! - If you'd like, compare with the pom.xml in the solutions folder
Notice that duplicate classes that cause the enforcer to complain were
found in the dependencies: regexp
and xalan
.
No Duplicate Classes Allowed!
- For duplicate transitive dependencies, add dependency exclusions.
- For duplications between direct dependencies, resolve or add
ignored classes to this rule's configuration.
Found in:
regexp:regexp:jar:1.3:runtime
xalan:xalan:jar:2.7.1:runtime
Duplicate classes:
org/apache/regexp/ReaderCharacterIterator.class
org/apache/regexp/REDebugCompiler.class
org/apache/regexp/REDemo.class
org/apache/regexp/RETest.class
org/apache/regexp/REUtil.class
org/apache/regexp/RESyntaxException.class
org/apache/regexp/REDemo$1.class
org/apache/regexp/RECompiler$RERange.class
org/apache/regexp/StreamCharacterIterator.class
org/apache/regexp/RECompiler.class
org/apache/regexp/StringCharacterIterator.class
org/apache/regexp/CharacterIterator.class
org/apache/regexp/recompile.class
org/apache/regexp/CharacterArrayCharacterIterator.class
org/apache/regexp/REProgram.class
org/apache/regexp/RE.class