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

[jira] [Commented] (MSHADE-104) Cannot shade aspectj library

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

yx91490 commented on MSHADE-104:
--------------------------------

How about add some explanation about <rawString> to official site?

> Cannot shade aspectj library
> ----------------------------
>
>                 Key: MSHADE-104
>                 URL: https://issues.apache.org/jira/browse/MSHADE-104
>             Project: Maven Shade Plugin
>          Issue Type: Bug
>    Affects Versions: 1.4
>            Reporter: Trask Stalnaker
>            Assignee: Benson Margulies
>            Priority: Major
>             Fix For: 1.6
>
>         Attachments: MSHADE-104-v3.patch, SimpleRelocator.patch, SimpleRelocatorTest-2.patch, SimpleRelocatorTest.patch, shaded-aspectjweaver-pom.xml
>
>
> SimpleRelocator.java performs path matching in canRelocatePath() using String.startsWith() which treats the relocation path as a non-regex but then performs path substitution in relocatePath() using String.replaceFirst() which treats the relocation path as a regex.
> The reason I care about this difference is that I'm trying to shade the AspectJ library, and one of its classes (org.aspectj.weaver.bcel.BcelShadow) uses the string literal
> "(I)Lorg/aspectj/lang/ProceedingJoinPoint;" which understandably doesn't get shaded by a normal relocation pattern, e.g.
>   <relocation>
>     <pattern>org.aspectj</pattern>
>     <shadedPattern>hidden.aspectj</shadedPattern>
>   </relocation>
> So I would like to hard-code an additional relocation pattern to handle this, e.g.
>   <relocation>
>     <pattern>(I)Lorg/aspectj/lang/ProceedingJoinPoint;</pattern>
>     <shadedPattern>(I)Lhidden/aspectj/lang/ProceedingJoinPoint;</shadedPattern>
>   </relocation>
> This almost works, but not quite because the parentheses get treated as a non-regex string in canRelocatePath() but then as a regex string in relocatePath().  I can escape the parentheses to make relocatePath() match, but then of course the escaping makes canRelocatePath() return false and then it never gets to relocatePath().
> I hope you will consider the attached patch which uses org.codehaus.plexus.util.StringUtils.replaceOnce() to perform a non-regex substitution instead of String.replaceFirst().  I don't think this will cause regression issues since the prior match in canRelocatePath() already performs a non-regex match.  I have attached a simple unit test as well (as a patch to the existing SimpleRelocatorTest.java).
> In case you're interested, here is a link to the "problem" AspectJ class:
> http://dev.eclipse.org/viewcvs/viewvc.cgi/org.aspectj/modules/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java?view=markup&root=Tools_Project
> (see text "(I)Lorg/aspectj/lang/ProceedingJoinPoint;" on line 2924)



--
This message was sent by Atlassian Jira
(v8.20.1#820001)