136*_*136 10 java compilation build gradle
我正在尝试构建一个 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
Run Code Online (Sandbox Code Playgroud)
做完之后Get-ChildItem -Path ./ -Filter .classpath -Recurse -Force
我得出结论,.classpath
我的项目中甚至没有一个文件名。我该怎么办?
Joã*_*los 77
与@korn的答案类似,我使用EXCLUDE
策略解决了我的问题;
tasks.withType<Jar>() {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes["Main-Class"] = "MainKt"
}
configurations["compileClasspath"].forEach { file: File ->
from(zipTree(file.absoluteFile))
}
}
Run Code Online (Sandbox Code Playgroud)
小智 48
jar {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
}
Run Code Online (Sandbox Code Playgroud)
Mor*_*eza 12
请添加这个
tasks.withType(Copy).all { duplicatesStrategy 'exclude' }
build.gradle
然后在文件中解决了它。
小智 7
我在使用 kotlin 和 gradle 7 构建时遇到了同样的问题。将以下代码添加到您的build.gradle.kts
.
tasks.withType<Jar> { duplicatesStrategy = DuplicatesStrategy.INHERIT }
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5298 次 |
最近记录: |