2

I'm trying to build a basic imagej plugin using bioformats to enable me to open czi files etc. However, when I add the bioformats dependency the maven plugin BanDuplicateClasses fails. These are the dependencies in my pom file

<dependencies>
    <dependency>
        <groupId>net.imagej</groupId>
        <artifactId>imagej</artifactId>
    </dependency>
    <dependency>
        <groupId>ome</groupId>
        <artifactId>bio-formats_plugins</artifactId>
        <version>6.1.0-m1</version>
    </dependency> 
</dependencies>

And the parent pom file where the maven plugin causing the problem seems to originate

<parent>
    <groupId>org.scijava</groupId>
    <artifactId>pom-scijava</artifactId>
    <version>26.0.0</version>
    <relativePath />
</parent>

This is the error that it throws when I try to package it

[WARNING] Rule 3: org.apache.maven.plugins.enforcer.BanDuplicateClasses failed with message: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:
    commons-io:commons-io:jar:2.6:runtime
    ch.systems.cisd:jhdf5:jar:14.12.0:compile
Duplicate classes:
    org/apache/commons/io/FileCleaningTracker.class
    org/apache/commons/io/comparator/SizeFileComparator.class
    org/apache/commons/io/output/ProxyWriter.class
    org/apache/commons/io/input/CloseShieldInputStream.class
    org/apache/commons/io/FileCleaningTracker$Tracker.class
    ..........

I tried to remove these dependencies from the bioformats dependency using

<exclusions>
    <exclusion>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
    </exclusion>
</exclusions>

but this didn't work (probably unsurprisingly since I don't know what I'm doing)

How do I go about fixing this?

Mike Davies
  • 487
  • 5
  • 14

1 Answers1

0

Just had the same problem. Fixed it by switching to version 27.0.1 for the pom-scijava parent.

Note that there is a bug in version 27.0.1, see https://forum.image.sc/t/pom-scijava-27-0-1-causes-error-assembling-jar-during-build/27167.

Jonas W
  • 373
  • 1
  • 4
  • 15