You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Robert Scholte (JIRA)" <ji...@apache.org> on 2018/11/21 19:09:00 UTC

[jira] [Commented] (MSHADE-304) Include specific files or directories for transformation - IncludeResourceTransformer?

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

Robert Scholte commented on MSHADE-304:
---------------------------------------

Best way is to implement your own [ResourceTransformer|https://maven.apache.org/plugins/maven-shade-plugin/apidocs/org/apache/maven/plugins/shade/resource/ResourceTransformer.html] and put its jar as dependency to the maven-shade-plugin in your pom.
https://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html shows examples of other transformers, which you can used as inspiration.

> Include specific files or directories for transformation -  IncludeResourceTransformer?
> ---------------------------------------------------------------------------------------
>
>                 Key: MSHADE-304
>                 URL: https://issues.apache.org/jira/browse/MSHADE-304
>             Project: Maven Shade Plugin
>          Issue Type: Improvement
>    Affects Versions: 3.2.1
>            Reporter: Alex
>            Priority: Minor
>              Labels: Transform, hk2, relocation, resources
>         Attachments: default
>
>
> *Background*
>  I am working at a project with the DI framework HK2.
> With HK2 it is possible to use _hk2-metadata-generator_ to generate a file ("META-INF/hk2-locator/default") containing all annotated @Service classes (and @ConfiguredBy annotations)  for the auto-discovery feature in HK2.
> For the configuration part (@ConfiguredBy) of HK2 i am using maven dependency hk2-configuration-integration (org.glassfish.hk2).
> See for more details also:
>  [https://javaee.github.io/hk2/configuration.html]
>  [https://javaee.github.io/hk2/inhabitant-generator.html]
> Example @ConfiguredBy annotation: [https://github.com/eclipse-ee4j/glassfish-hk2/tree/master/examples/configuration] 
>  
> *Issue/Improvement*
> With maven-shade i was able to configure relocation for specific dependencies which might be conflicting when used in other projects, which is a really cool feature i have to say!
> Only one manual step is now necessary for me (scripted at the moment) to adapt the generated file "META-INF/hk2-locator/default" and update the JAR to have a proper working JAR. 
>  See also attached example file [^default] (note the org.glassfish.hk2 scope defined there, which would require transformation/renaming i.e. org.shaded.glassfish..).
>  
> Maybe i am missing something which already exists with maven shade plugin, but i was not able to include a custom file to the transformation/relocation process, like in my described situation.
> I also tried to use "IncludeResourceTransformer" but when looking at the code no transformation is done there, it is just used for copying artifacts as far as i can tell? The name is a bit misleading, isn't it?
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)