1

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?

Aniruddh Parihar
  • 3,072
  • 3
  • 21
  • 39
Pramod S. Nikam
  • 4,271
  • 4
  • 38
  • 62

3 Answers3

3

The equivalent to Groovy DSL's

maven {
    url "https://repo.tools.telstra.com/repository/maven-public"
}

In Kotlin DSL is:

maven("https://plugins.gradle.org/m2/")
david.barkhuizen
  • 5,239
  • 4
  • 36
  • 38
kerelape
  • 114
  • 8
  • Please provide additional details in your answer. As it's currently written, it's hard to understand your solution. – Community Sep 08 '21 at 11:40
  • Thanks @ksviety - I added some more explanation to satisfy the the community admin, please take a look for future guidance. – david.barkhuizen Sep 14 '21 at 05:27
2

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/"))
} 
Pramod S. Nikam
  • 4,271
  • 4
  • 38
  • 62
0

This is already solved here How to add a maven repository by url using kotlinscript DSL (build.gradle.kts).

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

In Kotlin DSL would be

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

}