apache / apache/maven-shade-plugin
[MSHADE-304] Include specific files or directories for transformation - IncludeResourceTransformer?
- Dominant language
- Java
- Stars
- 188
- Forks
- 103
- Avg merge
- 16h 39m
- Merged PRs (30d)
- 4
Description
**[Alex](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=exas)** opened **[MSHADE-304](https://issues.apache.org/jira/browse/MSHADE-304?redirect=false)** and commented
**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?
---
**Affects:** 3.2.1
**Attachments:**
- [default](https://issues.apache.org/jira/secure/attachment/12949044/default) (_366 bytes_)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with IncludeResourceTransformer and the attached META-INF/hk2-locator/default example, then review how Maven Shade applies relocation to dependencies. Determine how a selected file or directory could participate in transformation and define completion as producing a shaded JAR whose HK2 metadata reflects the configured relocation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100