Extending Gradle DSL (RepositoryHandler)

I want to create a function in the Gradle DSL, specifically in org.gradle.api.artifacts.dsl.RepositoryHandler. I’m writing the plugin in Kotlin and releasing it to the gradle plugin portal.

fun RepositoryHandler.something(something: String) {
  maven { repo ->
    repo.name = something
    repo.url = URI.create("https://something.test/$something")
    repo.credentials { creds ->
      creds.username = System.getenv("SOMETHING_USERNAME")
      creds.password = System.getenv("SOMETHING_PASSWORD")
    }
  }
}

This works for build.gradle.kts files, but not with Groovy. Is there a better to way to create it? If so, please guide me the right way! <3

This is used in build.gradle(.kts)? files:

repositories {
  mavenCentral()
  something("something")
}

Hmm, let me think whether I will answer something different than in Slack, …, …, …, no, I think I just post a link to our conversation. :stuck_out_tongue:
https://www.linen.dev/s/gradle-community/t/14154073/hello-i-d-like-to-write-a-small-plugin-that-adds-a-function-