1

Based on the requirement at Maven dependency incompatible library class, I have tried shade plugin as like below, but went in vain.

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
    <execution>
        <phase>compile</phase>
        <goals>
            <goal>shade</goal>
        </goals>
        <configuration>
            <filters>
                <filter>
                    <artifact>com.lib:Encoder</artifact>
                    <includes>
                        <include>x/y/z/**</include>
                    </includes>
                    <excludes>
                        <exclude>a/b/c/**</exclude>
                    </excludes>
                </filter>
            </filters>
        </configuration>
    </execution>
</executions>

My target here is to replace the package with of a.b.c structure with x.y.z of classes. Did I miss any crucial configurations here?

Sats
  • 1,061
  • 9
  • 12

1 Answers1

1

To replace the package a.b.c with x.y.z on your shaded jar you should add the relocations entry as follow on maven-shade-plugin:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>3.1.0</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
            <configuration>
                <minimizeJar>true</minimizeJar>
                <relocations>
                    <relocation>
                        <pattern>x.y.z</pattern>
                        <shadedPattern>a.b.c</shadedPattern>
                    </relocation>
                </relocations>
            </configuration>
        </execution>
    </executions>
</plugin>
gregorycallea
  • 1,218
  • 1
  • 9
  • 28