You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Alexander Kriegisch (Jira)" <ji...@apache.org> on 2021/05/25 06:01:00 UTC

[jira] [Comment Edited] (MSHADE-197) Shade fails to relocate packages for all classes

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

Alexander Kriegisch edited comment on MSHADE-197 at 5/25/21, 6:00 AM:
----------------------------------------------------------------------

OK, I checked out your branch and got confirmation for what I asked you about before:
* You are trying to create an uber JAR containing both AWS S3 Java SDK and a relocated version of Apache HTTP Components.
* You do not need to compile anything from sources. You only need the sources for better IDE integrations, if someone wants to navigate your uber JAR's sources.
* There is absolutely no need to modify the AWS SDK sources, you can just create a module in your own project, creating the uber JAR there. A configuration similar to what you put into {{aws-java-sdk-s3/pom.xml}} should suffice.
* Even if you want to stick with your weird approach to abuse the AWS SDK project for generating the uber JAR, it works if you simply remove the Maven Shade Plugin again from {{aws-java-sdk-core/pom.xml}}. Shading the same thing twice is not going to help and just leads to the errors you saw. As soon as I reverted the change in that file and built the remainder of your modified AWS SDK project with {{mvn -DskipTests=true clean package -P versiondiff}}, it worked. Besides, you forgot to mention that you put the Shade plugin into the {{versiondiff}} Maven profile, for whatever reason. so of course, you also have to use that profile when building the project. You never mentioned that in your mailing list thread.

Having said all that, I can confirm that this is *not* a Maven Shade issue. The problem sat in front of the keyboard in this case. No problem, we all make mistakes. 🙂 But please, close the issue, I think it is resolved. I am just wondering why for so long no maintainer cared to reply to you. I am just a user (who lately contributed a few pull requests) like you.


was (Author: kriegaex):
OK, I checked out your branch and got confirmation for what I asked you about before:
* You are trying to create an uber JAR containing both AWS S3 Java SDK and a relocated version of Apache HTTP Components.
* You do not need to compile anything from sources. You only need the sources for better IDE integrations, if someone wants to navigate your uber JAR's sources.
* There is absolutely no need to modify the AWS SDK sources, you can just create a module in your own project, creating the uber JAR there. A configuration similar to what you put into {{aws-java-sdk-s3/pom.xml}} should suffice.
* Even if you want to stick with your weird approach to abuse the AWS SDK project for generating the uber JAR, it works if you simply remove the Maven Shade Plugin again from {{aws-java-sdk-core/pom.xml}}. Shading the same thing twice is not going to help and just leads to the errors you saw. As soon as I reverted the change in that file and built the remainder of your modified AWS SDK project with {{mvn -DskipTests=true clean package -P versiondiff}}, it worked. Besides, you forgot to mention that you put the Shade plugin into the {{versiondiff}} Maven profile, for whatever reason. so of course, you also have to use that profile when building the project. You never mentioned that in your mailing list thread.

Having said all that, I cann confirm that this is *not* a Maven Shade issue. The problem sat in front of the keyboard in this case. No problem, we all make mistakes. 🙂 But please, close the issue, I think it is resolved. I am just wondering why for so long no maintainer cared to reply to you. I am just a user (who lately contributed a few pull requests) like you.

> Shade fails to relocate packages for all classes
> ------------------------------------------------
>
>                 Key: MSHADE-197
>                 URL: https://issues.apache.org/jira/browse/MSHADE-197
>             Project: Maven Shade Plugin
>          Issue Type: Bug
>    Affects Versions: 2.4
>         Environment: Windows 7, Maven 3.0.5
>            Reporter: Michael McCarthy
>            Priority: Major
>
> I attempted to relocate the {{org.apache.http.*}} packages using the shade plugin on the AWS Java SDK. This fails to update the location for at least one class, {{com.amazonaws.services.s3.model.S3ObjectInputStream}}. I manually updated the source code to use the shaded location and it compiled without issue:
> {code}
> import org.shaded.http.client.HttpClient;
> import org.shaded.http.client.methods.HttpRequestBase;
> import org.shaded.http.conn.EofSensorInputStream;
> {code}
> Before making the above change, the error I get is:
> {noformat}
> [ERROR] 
> \dev\CSJ\aws\temp\aws-sdk-java\aws-java-sdk-s3\src\main\java\com\amazonaws\services\s3\internal\S3ObjectResponseHandler.java:[54,26]
> error: no suitable constructor found for S3ObjectInputStream(InputStream,org.shaded.http.client.methods.HttpRequestBase)
> {noformat}
> The configuration I used in pom.xml was:
> {code:xml}
> <plugin>
>     <groupId>org.apache.maven.plugins</groupId>
>     <artifactId>maven-shade-plugin</artifactId>
>     <version>2.4</version>
>     <configuration>
>        <artifactSet>
>           <includes>
>              <include>com.amazonaws:*</include>
> <include>org.apache.httpcomponents:*</include>
>           </includes>
>        </artifactSet>
>        <relocations>
>           <relocation>
>              <pattern>org.apache.http</pattern>
> <shadedPattern>org.shaded.http</shadedPattern>
>           </relocation>
>        </relocations>
>     </configuration>
>     <executions>
>        <execution>
>           <phase>package</phase>
>           <goals>
>              <goal>shade</goal>
>           </goals>
>        </execution>
>     </executions>
> </plugin>
> {code}
> See http://mail-archives.apache.org/mod_mbox/maven-users/201506.mbox/%3C558BE1C5.2020400%40tribloom.com%3E for more details. This thread has instructions on how to reproduce as well as links to a Github project with the changes already made and the error easy to reproduce.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)