我正在尝试构建一个 gradle 项目,但是当我尝试时$ gradle build
我得到以下输出:
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :jar FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':jar'.
> Entry .classpath is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/7.0/dsl/org.gradle.api.file.CopySpec.html#org.gradle.api.file.CopySpec:duplicatesStrategy for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 11s
4 actionable tasks: 2 executed, 2 up-to-date
做完之后Get-ChildItem -Path ./ -Filter .classpath -Recurse -Force
我的结论是
我什至没有一个名为.classpath
在我的项目中。我该怎么办?
与@korn的答案类似,我使用以下方法解决了我的问题EXCLUDE
战略;
tasks.withType<Jar>() {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes["Main-Class"] = "MainKt"
}
configurations["compileClasspath"].forEach { file: File ->
from(zipTree(file.absoluteFile))
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)