在 Gradle 6 中,我使用以下代码片段收集项目中的所有依赖项(使用 project.configurations.runtime
)并将它们复制到文件夹 "$buildDir/libs"
.
tasks.register<Copy>("copyDependenciesToLib") {
into("$buildDir/libs")
from(project.configurations.runtime)
doLast {
println("copyDependenciesToLib:\n ${project.configurations.runtime.get().files.joinToString("\n ") { it.absolutePath }}\n ->\n $buildDir/libs")
}
}
我目前正在迁移到 Gradle 7,IntelliJ 告诉我 runtime
无法解析,似乎已从 configuration
中删除?
您能否为我指明在 Gradle 7 中重现上述脚本行为的正确方向?
最佳答案
我自己找到了答案。
有人提出了类似的问题here .
Gradle has removed the runtime configuration在 Gradle 7 中。
相反,可以使用 runtimeClasspath
.
我们的复制
任务现在如下所示:
tasks.register<Copy>("copyDependenciesToLib") {
into("$buildDir/libs")
from(project.configurations.runtimeClasspath)
doLast {
println("copyDependenciesToLib:\n ${project.configurations.runtimeClasspath.get().files.joinToString("\n ") { it.absolutePath }}\n ->\n $buildDir/libs")
}
}
关于gradle - 如何收集 Gradle 7 中的所有依赖项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71478456/