Maven Shade Plugin - Exclude Relocation for Specific Dependency

27 views Asked by At

I am using the Maven Shade Plugin to create an uber JAR for my project, and I have a specific requirement regarding the shading and relocation of the com.google.common package.

In my existing configuration, I have the following relocation for com.google.common:

 <relocation>
    <pattern>com.google.common</pattern>
    <shadedPattern>com.googlesaxcloud.common</shadedPattern>
 </relocation>

Now, I want to exclude the relocation for com.google.common when a specific Delta jar is used. I've tried adding an additional relocation entry with an clause, but I'm not sure if this is the correct approach.

Here's what I have tried:

<relocation>
    <pattern>com.google.common</pattern>
    <shadedPattern>com.googlesaxcloud.common</shadedPattern>
</relocation>

<relocation>
    <pattern>com.google.common</pattern>
    <shadedPattern>com.googlesaxcloud.common</shadedPattern>
    <excludes>
        <!-- Exclude com.google.common for Delta dependencies -->
        <exclude>io.delta:*</exclude>
    </excludes>
</relocation>

Is this the right way to exclude the relocation for com.google.common when the Delta jar is present? If not, what's the correct approach?

0

There are 0 answers