Overlapping classes between maven artifact aspose-words-19.12-jdk17.jar and maven plugin aspose-words-19.12-shaping-harfbuzz-plugin.jar with maven-shade-plugin

Hello,

I use maven-shade-plugin to create an “uber-jar” with all dependencies included, including aspose.

When I compile, I have a warning about overlapping classes:

[WARNING] aspose-words-19.12-jdk17.jar, aspose-words-19.12-shaping-harfbuzz-plugin.jar define 6 overlapping classes:
[WARNING]   - com.aspose.words.BasicTextShaperCache
[WARNING]   - com.aspose.words.Cluster
[WARNING]   - com.aspose.words.FontFeature
[WARNING]   - com.aspose.words.Glyph
[WARNING]   - com.aspose.words.ITextShaper
[WARNING]   - com.aspose.words.ITextShaperFactory
[WARNING] maven-shade-plugin has detected that some class files are
[WARNING] present in two or more JARs. When this happens, only one
[WARNING] single version of the class is copied to the uber jar.
[WARNING] Usually this is not harmful and you can skip these warnings,
[WARNING] otherwise try to manually exclude artifacts based on
[WARNING] mvn dependency:tree -Ddetail=true and the above output.
[WARNING] See https://maven.apache.org/plugins/maven-shade-plugin

Excluding artifact is possible with this maven plugin, but I can’t find how to exclude the harfbuzz plugin. I tried this approach:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>3.4.1</version>
    <executions>
        <!-- CUT -->
    </executions>

    <configuration>
        <filters>
            <!-- CUT -->
            <filter>
                <artifact>com.aspose:aspose-words:jar:shaping-harfbuzz-plugin</artifact>
                <excludes>
                    <exclude>com.aspose.words.BasicTextShaperCache</exclude>
                    <exclude>com.aspose.words.Cluster</exclude>
                    <exclude>com.aspose.words.FontFeature</exclude>
                    <exclude>com.aspose.words.Glyph</exclude>
                    <exclude>com.aspose.words.ITextShaper</exclude>
                    <exclude>com.aspose.words.ITextShaperFactory</exclude>
                </excludes>
            </filter>
        </filters>
    </configuration>
</plugin>

Do you have any idea how I can resolve this issue?

Thank you for your time.

@tmunoz,

To get rid of this problem, you can simply remove the harfbuzz plugin from the dependencies list. In this case, your .pom will look something like this:

...
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.4.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                        <!-- put your configurations here -->
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>com.aspose</groupId>
            <artifactId>aspose-words</artifactId>
            <version>23.3</version>
            <classifier>jdk17</classifier>
        </dependency>
    </dependencies>
...

You hinted me toward a solution. I did:

<plugin>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-words</artifactId>
    <version>19.12</version>
    <configuration>
        <skip>true</skip>
    </configuration>
</plugin>

To skip the harfbuzz plugin from Aspose.

1 Like