类路径已弃用,kotlin 1.7.0

问题描述 投票:0回答:2

我在我的 kotlin 项目中使用了

classpath

但是

classpath 
在 kotlin 1.7.0 中已弃用。

请参阅 https://kotlinlang.org/docs/whatsnew18.html#deprecations-and-removals

In the notes for Kotlin 1.7.0 that the KotlinCompile task still had the deprecated Kotlin property classpath, which would be removed in future releases. 

我应该使用什么来代替类路径?

还有,应该怎么使用呢?

如果您能给我一个示例代码,那将非常有帮助。

如果有人理解,谢谢您的考虑。

android kotlin gradle classpath
2个回答
1
投票

您应该在项目中使用

plugins
build.gradle
文件:

plugins { 
     id("com.android.library") version "$agp_version" apply false 
     id("com.android.application") version "$agp_version" apply false 
     id("org.jetbrains.kotlin.android") version "$kotlin_version" apply false 
     id("org.jetbrains.kotlin.plugin.serialization") version "$kotlin_version" apply false 
     id("com.google.dagger.hilt.android") version "$hilt_version" apply false 
     id("androidx.navigation.safeargs") version "$nav_version" apply false 
     id("com.google.gms.google-services") version "$google_services_version" apply false 
     id("com.google.firebase.crashlytics") version "$crashlytics_version" apply false 
 }

这是完整文件链接


0
投票

您应该使用“库”属性而不是“类路径”,它对我来说工作得很好。请参阅 org.jetbrains.kotlin.gradle.tasks.KotlinCompile 类来探索更多细节。

以下为官方文档说明:

在 Kotlin 1.7.0 的注释中,KotlinCompile 任务仍然有 已弃用的 Kotlin 属性类路径,将在 未来的版本。现在,我们已将弃用级别更改为错误 KotlinCompile 任务的类路径属性。所有编译任务都使用 编译所需的库列表的库输入

© www.soinside.com 2019 - 2024. All rights reserved.