在 `settings.gradle.kts` 中使用 `dependencyResolutionManagement` 时,如何在 `gradle.build.kts` 中配置自定义 Maven 依赖项?

How does one configure custom maven dependency in `gradle.build.kts` while using `dependencyResolutionManagement` in `settings.gradle.kts`?

Gradle 在声明自定义 Maven 存储库时无法解析依赖项。它在自定义存储库而不是 Maven Central 中查找依赖项。

我目前拥有的:

// build.gradle.kts
repositories {
    maven {
        url = uri("https://maven.pkg.jetbrains.space/myTeam/p/myProject/maven")
        credentials {
            username = project.extra["space_usr"].toString()
            password = project.extra["space_pwd"].toString()
        }
    }
}
// settings.gradle.kts
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}

但我收到以下错误:Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'app/build.gradle.kts'

如果我删除 repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 然后我得到以下错误:

Could not determine the dependencies of task ':app:kaptDebugKotlin'.
> Could not resolve all dependencies for configuration ':app:kotlinKaptWorkerDependencies'.
  The project declares repositories, effectively ignoring the repositories you have declared in the settings.
  You can figure out how project repositories are declared by configuring your build to fail on project repositories.
  See https://docs.gradle.org/7.0-rc-1/userguide/declaring_repositories.html#sub:fail_build_on_project_repositories for details.
   > Could not find org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.4.32.
     Searched in the following locations:
       - https://maven.pkg.jetbrains.space/...
       - https://maven.pkg.jetbrains.space/...
     Required by:
         project :app

我可以在 settings.gradle.kts 中添加我的自定义 Maven 依赖项,但是 project.extra 不可访问并且需要明文(已编辑)

我发现这是不可能的,相反,我在 settings.gradle.kts 中声明了我的 maven 依赖项并使用了以下内容:

// settings.gradle.kts
maven {
    url = uri(""https://maven.pkg.jetbrains.space/myTeam/p/myProject/maven")
    name = "myProject"
    credentials(PasswordCredentials::class)
}

// gradle.properties
myProjectUsername = [username]
myProjectPassword = [password]