我正在将一个项目迁移到Gradle。
我有一些通过compile fileTree(dir: "libs/$it", include: '*.jar')
导入的本地部门
但是,不建议使用compile
。
但是如果我将其更改为implementation
那么我的任务将什么都不会复制(除了用runtime
清除的文件):
task copyToLib(type: Copy) {
from configurations.runtime
into "$buildDir/output/lib"
}
将
configurations.runtime
更改为.compile
或implementation
并没有帮助这是怎么回事?
最佳答案
documentation on the Gradle Java plugin显示配置runtime
已被弃用。它被runtimeOnly
配置所取代,该配置就像其名称一样,仅提供运行时相关性。但是,还有另一个称为runtimeClasspath
的配置,该配置扩展了runtimeOnly
,runtime
和implementation
的配置。
因此,只需替换示例中的配置即可:
task copyToLib(type: Copy) {
from configurations.runtimeClasspath
into "$buildDir/output/lib"
}
关于gradle - 用`implementation`代替`compile`替换`fileTree`会干扰复制库任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57110533/