我们可以将 kotlin 构建文件从 buildSrc 导入 settings.gradle 吗?

Can we import kotlin build files from buildSrc into settings.gradle?

这样的事情可能吗?目前,这导致无法解决 class 错误。

Settings.kt buildSrc 中的文件

object Settings {
    const val useLocal = true
}

settings.gradle

import com.example.android

gradle.ext {
   useLocal = Settins.useLocal
}

include ':app'

在 Gradle 的旧版本中(在 Gradle 6 之前)是可能的。

https://docs.gradle.org/current/userguide/upgrading_version_5.html#changes_to_plugins_and_build_scripts

Classes from buildSrc are no longer visible to settings scripts

Previously, the buildSrc project was built before applying the project’s settings script and its classes were visible within the script. Now, buildSrc is built after the settings script and its classes are not visible to it. The buildSrc classes remain visible to project build scripts and script plugins.