gradle - 用`implementation`代替`compile`替换`fileTree`会干扰复制库任务

标签 gradle

我正在将一个项目迁移到Gradle。

我有一些通过compile fileTree(dir: "libs/$it", include: '*.jar')导入的本地部门

但是,不建议使用compile

但是如果我将其更改为implementation
那么我的任务将什么都不会复制(除了用runtime清除的文件):

task copyToLib(type: Copy) {
    from configurations.runtime
    into "$buildDir/output/lib"
}

configurations.runtime更改为.compileimplementation并没有帮助

这是怎么回事?

最佳答案

documentation on the Gradle Java plugin显示配置runtime已被弃用。它被runtimeOnly配置所取代,该配置就像其名称一样,仅提供运行时相关性。但是,还有另一个称为runtimeClasspath的配置,该配置扩展了runtimeOnlyruntimeimplementation的配置。

因此,只需替换示例中的配置即可:

task copyToLib(type: Copy) {
    from configurations.runtimeClasspath
    into "$buildDir/output/lib"
}

关于gradle - 用`implementation`代替`compile`替换`fileTree`会干扰复制库任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57110533/

相关文章:

android - 给定多个 Maven 存储库,Gradle 将选择哪个依赖项?

android - 无法为锁定文件创建父目录

c++ - Android NDK 与谷歌测试

android - 由于未就 Android 许可证达成一致,通过 TFS 运行的 Gradle 构建失败

android - 将 -P 参数从 android studio 传递给 gradle

android - 如何在android studio中更新Gradle文件

reference - 如何在gradle中导出可执行jar,并且这个jar可以运行,因为它包含引用库

android - Gradle 同步时间太长 Firebase-core 无法 HEAD 状态代码 409

java - 更新 gradle 包装文件会产生不同的结果

android - Glide 库 java.lang.NoClassDefFoundError