gpt4 book ai didi

java - 影子插件 Gradle : What does mergeServiceFiles() do?

转载 作者:搜寻专家 更新时间:2023-10-30 19:45:28 27 4
gpt4 key购买 nike

在我的 build.gradle 文件中,我需要添加以下行:

shadowJar {
mergeServiceFiles()
}

否则 jar 无法正常运行。我想知道这条线到底是做什么的?我在 Eclipse Luna 中使用 Gradle 插件。我在一个依赖于另一个 Java 项目的 Java 项目上创建了 jar。

最佳答案

mergeServiceFiles 声明为 here其实现如下:

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

如您所见,它使用定义为 hereServiceFileTransfomer .从它的文档:

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

Resources transformer that appends entries in META-INF/services resources into a single resource. For example, if there are several META-INF/services/org.apache.maven.project.ProjectBuilder resources spread across many JARs the individual entries will all be concatenated into a single META-INF/services/org.apache.maven.project.ProjectBuilder resource packaged into the resultant JAR produced by the shading process.

关于java - 影子插件 Gradle : What does mergeServiceFiles() do?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32887966/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com