簡體   English   中英

配置 Gradle Kotlin DSL 以使用自定義存儲庫

[英]Configure Gradle Kotlin DSL to work with custom repository

我正在處理一個項目,在該項目中,我們不使用默認存儲庫(Maven Central、jCenter 等),而是使用內部 JFrog 存儲庫。 該項目使用 Kotlin DSL for Gradle。

問題是,即使在settings.gradle.kts文件中配置pluginManagement塊,Gradle 仍然嘗試從 Gradle Central Plugin Repository 獲取依賴項

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

// other definitions

失敗消息:

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

有誰知道我做錯了什么?

如果要為buildSrc腳本配置插件存儲庫,則需要在buildSrc目錄中創建專用的settings.gradle[.kts]文件並在buildSrc配置pluginManagement {}塊。

實際上, buildSrc是一種單獨的構建,在評估/執行主構建之前首先執行。 因此,如果您想在buildSrc腳本中使用這些自定義存儲庫,則buildSrc在根項目的settings.gradle配置pluginManagement {}塊。

看起來您錯過了公司緩存中的 Gradle Plugin Repository maven 存儲庫。 只需確保包含https://plugins.gradle.org/m2/ 該錯誤確切地表明它未能找到插件

Gradle 插件通常列在那里,插件依賴項是從jcenter獲取的

順便提一句。 我們今天有 Kotlin 1.3.20 ,也許升級是有意義的

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM