You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Elliott Clark (JIRA)" <ji...@apache.org> on 2015/08/11 02:10:46 UTC

[jira] [Commented] (MSHADE-156) shade plugin is transforming also strings that are not supposed to be transformed

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

Elliott Clark commented on MSHADE-156:
--------------------------------------

Pretty sure that we're seeing this in https://issues.apache.org/jira/browse/HBASE-13889


We have the shad plugin configured like so:
{code}
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                            <configuration>
                                <shadedArtifactAttached>false</shadedArtifactAttached>
                                <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
                                <dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
                                <artifactSet>
                                    <includes>
                                        <include>*:*</include>
                                    </includes>
                                    <excludes>
                                        <exclude>org.apache.hbase:hbase-resource-bundle</exclude>
                                        <exclude>org.slf4j:*</exclude>
                                        <exclude>com.google.code.findbugs:*</exclude>
                                        <exclude>com.github.stephenc.findbugs:*</exclude>
                                        <exclude>org.apache.htrace:*</exclude>
                                        <exclude>log4j:*</exclude>
                                        <exclude>commons-logging:*</exclude>
                                    </excludes>

                                </artifactSet>
                                <relocations>
                                    <relocation>
                                        <pattern>com</pattern>
                                        <shadedPattern>org.apache.hadoop.hbase.shaded.com</shadedPattern>
                                        <excludes>
                                            <exclude>com.sun.**</exclude>
                                            <exclude>com.ibm.**</exclude>
                                        </excludes>
                                    </relocation>
                                    <relocation>
                                        <pattern>net</pattern>
                                        <shadedPattern>org.apache.hadoop.hbase.shaded.net</shadedPattern>
                                    </relocation>
                                    <relocation>
                                        <pattern>io</pattern>
                                        <shadedPattern>org.apache.hadoop.hbase.shaded.io</shadedPattern>
                                    </relocation>
                                    <relocation>
                                        <pattern>org</pattern>
                                        <shadedPattern>org.apache.hadoop.hbase.shaded.org</shadedPattern>
                                        <excludes>
                                            <exclude>org.apache.hadoop.**</exclude>
                                            <exclude>org.apache.commons.logging.**</exclude>
                                            <exclude>org.w3c.**</exclude>
                                            <exclude>org.xml.**</exclude>
                                            <exclude>org.slf4j.**</exclude>
                                        </excludes>
                                    </relocation>
                                </relocations>
                                <transformers>
                                  <!-- Need to filter out some extraneous license files.
                                       Don't use the ApacheLicenseRT because it just removes all
                                       META-INF/LICENSE(.txt)? files, including ours. -->
                                  <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
                                    <resources>
                                      <resource>LICENSE.txt</resource>
                                      <resource>ASL2.0</resource>
                                    </resources>
                                  </transformer>
                                  <!-- Where notices exist, just concat them -->
                                  <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer">
                                    <addHeader>false</addHeader>
                                    <projectName>${project.name}</projectName>
                                  </transformer>
                                </transformers>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
{code}

This is relocating strings like: {code}"com.sun.security.auth.UnixPrincipal"{code} to {code}"org/apache/hadoop/hbase/shaded/com.sun.security.auth.module.UnixLoginModule"{code}

> shade plugin is transforming also strings that are not supposed to be transformed
> ---------------------------------------------------------------------------------
>
>                 Key: MSHADE-156
>                 URL: https://issues.apache.org/jira/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.3.4#6332)