You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Trask Stalnaker (JIRA)" <ji...@codehaus.org> on 2011/08/22 07:36:32 UTC

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

     [ https://jira.codehaus.org/browse/MSHADE-104?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Trask Stalnaker updated MSHADE-104:
-----------------------------------

    Attachment: SimpleRelocatorTest-2.patch

Oops, updated patch file for the unit test attached.

> Cannot shade aspectj library
> ----------------------------
>
>                 Key: MSHADE-104
>                 URL: https://jira.codehaus.org/browse/MSHADE-104
>             Project: Maven 2.x Shade Plugin
>          Issue Type: Bug
>    Affects Versions: 1.4
>            Reporter: Trask Stalnaker
>         Attachments: SimpleRelocator.patch, SimpleRelocatorTest-2.patch, SimpleRelocatorTest.patch
>
>
> 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 is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira