Gradle构建错误

时间:2016-06-24 09:28:21

标签: gradle build build.gradle

我尝试使用gradle构建一个fatJar,但不幸的是它不起作用。给我这个错误

Cannot create directory 'C:\Users\User\build\tmp\expandedArchives\maven-toolchain-1.0.jar_6m0pv69i8jujen0j76d9kruaz\META-INF' as it already exists, but is not a directory
Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.2.1-bin.zip'.

这个错误到底是什么?

我有以下代码:

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

1 个答案:

答案 0 :(得分:0)

我只是使用这种“模式”解决了这个问题。

jar {

archiveName = "myjar.jar"

manifest {
    attributes 'Implementation-Title': 'myjar.jar',
               'Implementation-Version': version
}
// adds runtime dependencies to jar package
from(configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }) {
    // remove all signature files
    exclude "META-INF/*.SF"
    exclude "META-INF/*.DSA"
    exclude "META-INF/*.RSA"
}

}