Rafael Toledo
Rafael Toledo

Reputation: 5649

Configure Gradle Kotlin DSL to work with custom repository

I'm working on a project where, instead of using the default repositories (Maven Central, jCenter, and so), we are using an internal JFrog repository. The project is using Kotlin DSL for Gradle.

The problem is, even configuring the pluginManagement block inside the settings.gradle.kts file, Gradle still tries to fetch dependencies from Gradle Central Plugin Repository

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

// other definitions

Failing message:

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

Does anyone know what I am doing wrong?

Upvotes: 1

Views: 7129

Answers (2)

M.Ricciuti
M.Ricciuti

Reputation: 12086

If you want to configure the plugin repositories for your buildSrc script, you need to create a dedicated settings.gradle[.kts] file inside the buildSrc directory and configure the pluginManagement {} block there.

Indeed, buildSrc is a kind of separate build , which is executed first , before the main build is evaluated/executed. So you cannot configure the pluginManagement {} block in the root project's settings.gradle if you want to use these custom repositories in the buildSrc script.

Upvotes: 8

Eugene Petrenko
Eugene Petrenko

Reputation: 4982

It looks like you miss Gradle Plugin Repository maven repository in your corporate cache. Just make sure you have the https://plugins.gradle.org/m2/ included. The error shows exactly that it failed to find the plugin

Gradle plugins are normally listed there and the plugin dependencies are fetched from jcenter

BTW. We have Kotlin 1.3.20 today, maybe it makes sense to upgrade

Upvotes: -2

Related Questions