I am using shade plugin to create a jar with all its dependencies. Applying this configuration in my pom.xml it has been relatively straightforward:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<relocations>
<relocation>
<shadedPattern>com.company.lib.</shadedPattern>
<excludes>
<exclude>java.**</exclude>
<exclude>com.company.app.**</exclude>
<exclude>META-INF/**</exclude>
</excludes>
</relocation>
</relocations>
</configuration>
However, decompiling the resultant code, I have realized that the content of my String literals have been changed. For example, an string like this:
String text = "this-is-a-demo";
It has become String text = "com.company.lib.this-is-a-demo"
. This change has carried out runtime errors in my application.
Following this article https://jira.codehaus.org/browse/MSHADE-104, I have tried to avoid this adding the element <rawString>true</rawString>
. But when I have built the project again, a NullPointerException has happened in maven-shade-plugin.
Caused by: org.apache.maven.plugin.MojoExecutionException: Error creating shaded jar: null
at org.apache.maven.plugins.shade.mojo.ShadeMojo.execute(ShadeMojo.java:567)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Does anyone know how can I avoid the String literals being changed?