Gradle Shadow plugin relocate an SPI service while preserving the service file name in META-INF/services

25 Views Asked by At

I wonder how can I package a JAR with Gradle Shadow plugin where one would relocate a third-party Service Provider (SPI) while preserving the service file name in META-INF/services (just the name, the content should be relocated)?

Example of what I want to achieve:

INPUT:

/java
  /some/Service.class                
/resources
  /META-INF/services/some.Service

OUTPUT (following shadow relocate):

/java
        
   /relocated/Service.class 
/resources
   /META-INF/services/some.Service    <<< The filename intact while the content relocated

I have tried various exclude strategies with no success. My current theory would be that I would need to add an additional JAR step that would unpack the ShadowJar, rename the file and re-package the Jar.

0

There are 0 best solutions below