如何收集 Gradle 7 中的所有依赖项?
在 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 中重现上述脚本行为的正确方向吗?
With Gradle 6 I used following snippet to collect all dependencies in my project (using project.configurations.runtime
) and copy them to a folder "$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")
}
}
I am currently migrating to Gradle 7, and IntelliJ tells me that runtime
cannot be resolved, it seems that it has been removed from configuration
?
Can you point me in the right direction to reproduce the behavior of the above script in Gradle 7?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己刚刚找到了答案。
此处提出了类似的问题。
Gradle 已在 Gradle 7 中删除了运行时配置
。可以使用
运行时类路径
。我们的
copy
任务现在如下所示:I just found the answer myself.
A similar question has been asked here.
Gradle has removed the runtime configuration in Gradle 7.
Instead, one can use
runtimeClasspath
.Our
copy
task now looks the following: