Why does relocation with the maven shade plugin not work? Why does relocation with the maven shade plugin not work? hadoop hadoop

Why does relocation with the maven shade plugin not work?


This worked for me:

<relocations>   <relocation>     <pattern>com.google.</pattern>     <shadedPattern>thirdparty.com.google.</shadedPattern>   </relocation> </relocations>

note the dot at the end of the pattern.


You may need to specify explicit artifactSet::includes under your <configuration> section:

    <configuration>        <artifactSet>            <includes>                <include>com.google.guava:*</include>                ...            </includes>        </artifactSet>        <relocations>        ...


Seems like you need to refer to the package name in the relocation rule, not the maven groupId, I'm using rx v1 in my lib and don't want to pollute the user's namespace with it, the pom.xml section below rewrites the bytecode, so the final uberjar will have rx, but renamed (shaded.rx).

shade relocation doc

<plugin>  <groupId>org.apache.maven.plugins</groupId>  <artifactId>maven-shade-plugin</artifactId>  <version>3.0.0</version>  <executions>    <execution>      <phase>package</phase>        <goals>          <goal>shade</goal>        </goals>        <configuration>          <relocations>            <relocation>              <pattern>rx</pattern>              <shadedPattern>shaded.rx</shadedPattern>            </relocation>          </relocations>        </configuration>      </execution>    </executions>  </plugin>