我想用gradle做一个胖jar。我遇到了一个类似于针对grad尔的错误。不幸的是,我对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
我创建胖jar的gradle代码如下:
jar {
manifest {
attributes 'Main-Class': mainClassName,
'Implementation-Version': version
}
from {
configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
}
}
2条答案
按热度按时间ev7lccsx1#
在找了一整天的解决方法后,我发现一个5分钟后,我发布了我的问题。。。
这不是一个理想的解决办法,因为它排除了许可证,但我得到它通过以下工作。如果有人有更好的解决方案,我会非常感兴趣。
chhqkbe12#
build fat jar的my build.gradle:
https://gist.github.com/antowka/cab25f17cd704eaefdc8