Avatar ·

How to add a Maven repository by URL in build.gradle.kts using Kotlin DSL

Hello everyone! I'm migrating from Groovy to Kotlin DSL in Gradle and encountered a problem when adding an external Maven repository.

Previously, in build.gradle, I wrote it like this:

repositories {\n    maven { url "https://jitpack.io" }\n    mavenCentral()\n}

Now I'm rewriting the file to build.gradle.kts and trying to do the same:

repositories {\n    maven { url = "https://jitpack.io" }\n    mavenCentral()\n}

But Gradle throws an error:

Unresolved reference: url\nType mismatch: inferred type is String but URI was expected

I've tried different options: url("https://jitpack.io"), maven("https://jitpack.io"), but nothing works correctly. Please advise.