我正在尝试使用Gradle创建一个胖罐。我遇到了与此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
我创建胖罐的gradle代码如下:
jar {
manifest {
attributes 'Main-Class': mainClassName,
'Implementation-Version': version
}
from {
configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
}
}
答案 0 :(得分:4)
在搜索了一整天寻找解决方法后,我在发布问题后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
}
}
答案 1 :(得分:0)
我的build.gradle for build fat jar: