gpt4 book ai didi

创建 fat jar 时 Gradle 错误

转载 作者:行者123 更新时间:2023-12-02 09:57:17 25 4
gpt4 key购买 nike

我正在尝试使用 Gradle 创建一个 fat jar。我遇到了类似于此的错误 raised against Gradle 。不幸的是,我对 Gradle 和 Groovy 的了解还不够,无法想出一个创造性的解决方法,所以我希望这里有人能够提供帮助。我在网上搜索了各种解决方法但无济于事:(

我的特殊冲突与 Apache Storm 依赖项有关:

...
Caused by: org.gradle.api.GradleException: Could not copy zip entry /Users/DefaultUser/.gradle/caches/modules-2/files-2.1/org.apache.storm/storm-core/0.10.0-beta1/c3ba45e5ba616335c9f4be12317a8ebf2d2f17ba/storm-core-0.10.0-beta1.jar!META-INF/license/LICENSE.base64.txt to '/Users/DefaultUser/Projects/streams/build/tmp/expandedArchives/storm-core-0.10.0-beta1.jar_6i3o5dzb4lwfvasqr1cg4giqy/META-INF/license/LICENSE.base64.txt'.
at org.gradle.api.internal.file.AbstractFileTreeElement.copyTo(AbstractFileTreeElement.java:79)
at org.gradle.api.internal.file.archive.ZipFileTree$DetailsImpl.getFile(ZipFileTree.java:125)
at org.gradle.api.internal.file.AbstractFileTree$1.visitFile(AbstractFileTree.java:39)
at org.gradle.api.internal.file.AbstractFileTree$FilteredFileTree$1.visitFile(AbstractFileTree.java:145)
at org.gradle.api.internal.file.archive.ZipFileTree.visit(ZipFileTree.java:90)
... 50 more
Caused by: org.gradle.api.UncheckedIOException: Cannot create directory '/Users/DefaultUser/Projects/streams/build/tmp/expandedArchives/storm-core-0.10.0-beta1.jar_6i3o5dzb4lwfvasqr1cg4giqy/META-INF/license' as it already exists, but is not a directory
at org.gradle.util.GFileUtils.mkdirs(GFileUtils.java:261)
at org.gradle.api.internal.file.AbstractFileTreeElement.copyTo(AbstractFileTreeElement.java:73)
... 54 more

我创建fat jar的gradle代码如下:

jar {

manifest {
attributes 'Main-Class': mainClassName,
'Implementation-Version': version
}

from {
configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
}
}

最佳答案

在寻找一整天的解决方法后,我在发布问题 5 分钟后找到了一个解决方法......

这不是一个理想的解决方法,因为它排除了许可证,但是我通过以下方法让它工作。如果有人有更好的解决方案,我会非常感兴趣。

jar {

from(configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }) {
exclude "META-INF/*.SF"
exclude "META-INF/LICENSE"
}

manifest {
attributes 'Main-Class': mainClassName,
'Implementation-Version': version
}

}

关于创建 fat jar 时 Gradle 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31599848/

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