kotlin gradle dsl problem : Type mismatch: inferred type is String but URI! was expected

Issue

I am trying to convert Gradle's Groovy DSL to Kotlin DSL

Gradle Groovy Code is :

 repositories {
        maven {
            url "https://repo.tools.telstra.com/repository/maven-public"
        }
        mavenCentral()
        maven {
            url 'https://plugins.gradle.org/m2/'
        }
    }

I am trying this to convert into Kotlin DSL, like below:

 repositories {
        maven { url   ("https://repo.tools.telstra.com/repository/maven-public") }
        mavenCentral()
        maven { url   ('https://plugins.gradle.org/m2/') }
    }

With that I am getting error as:

Type mismatch: inferred type is String but URI! was expected

How can I setup URI here?

Solution

At the moment I am using Gradle 6.9, there we have to write it like below:

repositories {
    maven(url  uri("https://repo.tools.telstra.com/repository/maven-public"))
    mavenCentral()
    maven( url  uri("https://plugins.gradle.org/m2/"))
} 

Answered By – Pramod S. Nikam

Leave a Comment