gpt4 book ai didi

gradle - DefaultSourceDirectorySet 构造函数已被弃用。如何使用ObjectFactory服务?

转载 作者:行者123 更新时间:2023-12-01 22:18:03 24 4
gpt4 key购买 nike

我最近更新到 gradle 版本 5.0-rc-4,当运行 ./gradlew assemble (或任何其他任务)时,我现在收到以下消息:

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.

当我使用./gradlew assemble --warning-mode all时,我得到:

> Configure project :
The DefaultSourceDirectorySet constructor has been deprecated. This is scheduled to be removed in Gradle 6.0. Please use the ObjectFactory service to create instances of SourceDirectorySet instead.

但是在下面的build.gradle中,我没有看到我在哪里使用任何DefaultSourceDirectorySet,所以这个警告是什么,我需要做什么更改为与 Gradle 6.0 兼容?

plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.10'
}

dependencies {
compile 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
}

repositories {
mavenCentral()
mavenLocal()
jcenter()
}

相关

我找到了create version.txt file in project dir via build.gradle task(gradle 5.0)但我没有这样的构造,所以我不知道它如何应用。

我发现发行说明中提到了此弃用 https://docs.gradle.org/5.0-milestone-1/release-notes.html但他们说

In this release of Gradle, the ObjectFactory service, which is part of the public API, now includes a method to create SourceDirectorySet instances. Plugins can now use this method instead of the internal types.

但我不知道如何。

我还在 https://docs.gradle.org/current/javadoc/org/gradle/api/file/SourceDirectorySet.html 找到了 SourceDirectorySet 接口(interface)但我不知道如何使用它。

模板存储库:https://github.com/PHPirates/kotlin-template-project

最佳答案

更新 2019-01-23 五分钟前,kotlin 1.3.20 为 released并在 Gradle repository 中进行了更新所以这个问题应该通过将 Kotlin Gradle 插件更新到 1.3.20 来解决。

更新2019-01-11目标版本在Youtrack issue KT-26808刚刚更新到1.3.20。您可以在 Gradle 存储库中查看最新发布的版本 here ,但是目前还有很多open issues for 1.3.20 .

更新 2018-12-17 弃用警告已在提交 https://github.com/JetBrains/kotlin/commit/67e82a54e5ee529116e881953f93a4c8f216e33a 中修复,Youtrack 问题已关闭。现在等待release推出。

作为@Javaru pointed out ,这已在 Youtrack issue KT-26808 上报告过(2018 年 9 月) .

使用来自Lance's comment的信息在链接中Thomas David Baker pointed to :

答案:

如果您在不直接使用 DefaultSourceDirectorySet 时收到此警告,则这可能来自您使用的 Gradle 插件。您可以使用 Gradle 构建的 --warning-mode all --stacktrace 标志来检查这一点,就像 ./gradlew assemble --warning-mode all --stacktrace .

在这个特殊情况下,它是 Kotlin Gradle 插件,他们在 DefaultKotlinSourceSet.kt#L140-L155 使用它。 :

private val createDefaultSourceDirectorySet: (name: String?, resolver: FileResolver?) -> SourceDirectorySet = run {
val klass = DefaultSourceDirectorySet::class.java
val defaultConstructor = klass.constructorOrNull(String::class.java, FileResolver::class.java)

if (defaultConstructor != null && defaultConstructor.getAnnotation(java.lang.Deprecated::class.java) == null) {
// TODO: drop when gradle < 2.12 are obsolete
{ name, resolver -> defaultConstructor.newInstance(name, resolver) }
} else {
// (code omitted)
}
}

我们可以相信他们会及时解决问题,因此不必担心警告。

关于gradle - DefaultSourceDirectorySet 构造函数已被弃用。如何使用ObjectFactory服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53461821/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com