配置 Gradle Kotlin DSL 以使用自定义存储库

Raf*_*edo 1 gradle kotlin

我正在开发一个项目,我们不使用默认存储库(Maven Central、jCenter 等),而是使用内部 JFrog 存储库。该项目使用 Kotlin DSL for Gradle。

问题是,即使配置文件pluginManagement内的块settings.gradle.kts,Gradle 仍然尝试从 Gradle Central Plugin Repository 获取依赖项

// settings.gradle.kts
pluginManagement {
    repositories {
        maven(url = "https://myinternalrepo.corp/artifactory")
    }
}

// other definitions
Run Code Online (Sandbox Code Playgroud)

失败消息:

Plugin [id: 'org.gradle.kotlin.kotlin-dsl', version: '1.1.3'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:1.1.3')
  Searched in the following repositories:
    Gradle Central Plugin Repository
Run Code Online (Sandbox Code Playgroud)

有谁知道我做错了什么?

M.R*_*uti 5

如果您想为buildSrc脚本配置插件存储库,则需要settings.gradle[.kts]在目录内创建一个专用文件buildSrc并在其中配置pluginManagement {}块。

事实上,buildSrc它是一种单独的构建,在评估/执行主构建之前首先执行。因此,如果您想在脚本中使用这些自定义存储库,则无法pluginManagement {}在根项目中配置该块。settings.gradlebuildSrc