Uploaded image for project: 'Maven Shade Plugin'
  1. Maven Shade Plugin
  2. MSHADE-229

Add ability for ServicesResourceTransformer to rename files

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.4.3
    • None
    • None

    Description

      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

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            rfscholte Robert Scholte
            rsand Richard Sand
            Votes:
            3 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment