Shadow Plugin Gradle: What does mergeServiceFiles () do?

In my build.gradle file I need to add the line:

shadowJar { mergeServiceFiles() } 

Otherwise, the bank is not working properly. I wonder what exactly this line does? I am using the Gradle plugin in Eclipse Luna. I am creating a jar on one Java project, which depends on another.

+13
source share
1 answer

mergeServiceFiles declared here, and its implementation is as follows:

 /** * Syntactic sugar for merging service files in JARs * @return */ public ShadowJar mergeServiceFiles() { try { transform(ServiceFileTransformer.class); } catch (IllegalAccessException e) { } catch (InstantiationException e) { } return this; } 

As you can see, it uses the ServiceFileTransfomer which is defined here . From his documents:

Changed from org.apache.maven.plugins.shade.resource.ServiceResourceTransformer.java

A resource converter that adds META-INF / services resource records to a single resource. For example, if there are several META-INF / services / org.apache.maven.project.ProjectBuilder resources distributed across many JAR files, all individual entries will be merged into one META-INF / services / org.apache.maven.project. The .ProjectBuilder resource is packaged in the resulting JAR file created by the shader process.

+8
source

Source: https://habr.com/ru/post/1232712/


All Articles