You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Eric Anderson (JIRA)" <ji...@apache.org> on 2016/08/02 20:06:20 UTC

[jira] [Commented] (MSHADE-229) Add ability for ServicesResourceTransformer to rename files

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

Eric Anderson commented on MSHADE-229:
--------------------------------------

This is effectively the same issue as MSHADE-221. I encountered it myself and independently developed a patch that looks very similar to the one already here. This impacted users of grpc and jackson that wanted to shade the library, although there are workarounds.

> Add ability for ServicesResourceTransformer to rename files
> -----------------------------------------------------------
>
>                 Key: MSHADE-229
>                 URL: https://issues.apache.org/jira/browse/MSHADE-229
>             Project: Maven Shade Plugin
>          Issue Type: Improvement
>    Affects Versions: 2.4.3
>            Reporter: Richard Sand
>         Attachments: shade srt.patch
>
>
> The ServicesResoureTransformer can transform the contents of files in META-INF/services - however, often the names of these files also follow the package hierarchy. Simple example is commons-logging, where it creates a service META-INF/services/org.apache.commons.logging.LogFactory containing the full name of the default LogFactory class. So in addition to transforming the file contents, we want to transform the file names as well.
> Sometimes this is a requirement to create a working shaded jar. For example, if you are using Jersey JAX-RS, or any project using Glassfish HK2, you will find that your shaded jar fails because these services files are now expected to have been renamed along with the class relocation rules.
> I've added a patch to this case that augments ServicesResourceTransformer to add this capability. It adds a new Boolean "renamFiles" - which defaults to "false" to preserve existing functionality. But when sent to true, it will send each resource filename through the relocators, so that "META-INF\services\org.glassfish.hk2.extension.ServiceLocatorGenerator" is renamed to "com.idfconnect.relocated.org.glassfish.hk2.extension.ServiceLocatorGenerator", as well as having its contents updated as well. With this fix In place, I've easily encapsulated Jersey and my logging framework into a shaded jar that works just fine.
> The fix is very easy and only a few lines of code and provides a useful new feature. I hope the development community agrees and accepts this patch into the next release



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)