[ 
https://jira.codehaus.org/browse/MSHADE-156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=346884#comment-346884
 ] 

Jon McLean commented on MSHADE-156:
-----------------------------------

I have a similar issue.  In my case the incorrect transform causes runtime 
issues.  I am using maven-shade 2.3.

I want to shade and relocate all dependencies so I do not specify any 
"includes" in the shade configuration.  This causes the SimpleRelocater to 
relocate everything that does not specifically start with the excluded string.  

{code:title=pom.xml|borderStyle=solid}
<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.3</version>
        <configuration>
                <minimizeJar>false</minimizeJar>
                
<keepDependenciesWithProvidedScope>false</keepDependenciesWithProvidedScope>
                
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml
                </dependencyReducedPomLocation>
                <relocations>
                        <relocation>
                                <shadedPattern>shaded.</shadedPattern>
                                <excludes>
                                        <exclude>my.project.package.**</exclude>
                                        <exclude>java.**</exclude>
                                        <exclude>javax.**</exclude>
                                        <exclude>META-INF/**</exclude>
                                </excludes>
                        </relocation>
                </relocations>
                <artifactSet>
                        <excludes>
                                <exclude>javax.*</exclude>
                                
<exclude>com.google.code.findbugs:jsr305</exclude>
                        </excludes>
                </artifactSet>
                <shadedArtifactAttached>false</shadedArtifactAttached>
        </configuration>
        <executions>
                <execution>
                        <phase>package</phase>
                        <goals>
                                <goal>shade</goal>
                        </goals>
                </execution>
        </executions>
</plugin>
{code}

Here is a sample from my project:
{code:title=Original.java|borderStyle=solid}
public class UCDConstants
{
  public static final Charset UTF8 = Charset.forName("utf-8");
}
{code}

After the maven-shade-plugin runs the charset is "shaded.utf-8."  This causes 
runtime issues because that charset does not exist.
{code:title=Shaded.java|borderStyle=solid}
public class UCDConstants
{
  public static final Charset UTF8 = Charset.forName("shaded.utf-8");
}
{code}


> shade plugin is transforming also strings that are not supposed to be 
> transformed
> ---------------------------------------------------------------------------------
>
>                 Key: MSHADE-156
>                 URL: https://jira.codehaus.org/browse/MSHADE-156
>             Project: Maven Shade Plugin
>          Issue Type: Bug
>    Affects Versions: 2.1
>            Reporter: Neeme Praks
>
> I'm shading several third party libraries into a single JAR. In the context 
> of this issue, there are two important libraries:
> 1. com.nothome:javaxdelta:2.0.1 - this library is in "at.spardat.xma.xdelta" 
> package.
> 2. ch.qos.logback:logback-classic:1.0.11 - in this library, in class 
> ch.qos.logback.classic.spi.StackTraceElementProxy, there is a method to 
> convert stack trace elements into strings:
> {code}
>   public String getSTEAsString() {
>     if (steAsString == null) {
>       steAsString = "at " + ste.toString();
>     }
>     return steAsString;
>   }
> {code}
> I use "org.myorgname.appname.shaded" package for shading.
> During shading, the constant "at " is replaced with 
> "org.myorgname.appname.shaded.at" -- shade plugin thinks that the "at" in the 
> beginning of that string is a package name and shades it.
> This results in an unfortunate side-effect: all logged stack traces now look 
> like this:
> {noformat}
> Caused by: java.util.zip.ZipException: error in opening zip file
>       org.myorgname.appname.shaded.at java.util.zip.ZipFile.open(Native 
> Method) ~[na:1.6.0_19]
>       org.myorgname.appname.shaded.at 
> java.util.zip.ZipFile.<init>(ZipFile.java:114) ~[na:1.6.0_19]
>       org.myorgname.appname.shaded.at 
> java.util.zip.ZipFile.<init>(ZipFile.java:131) ~[na:1.6.0_19]
> {noformat}
> Possible fixes:
> * instead of just checking the first part of the package (at), check for the 
> full package (at.spardat.xma.xdelta).
> * allow to configure shade plugin to ignore certain string constants in 
> certain classes (this would solve also some other issues we have with shade 
> plugin being too eager).
> * both of the above.



--
This message was sent by Atlassian JIRA
(v6.1.6#6162)

Reply via email to