MavenLocal repository only for snapshots with the Gradle Kotlin DSL

Sometimes, while developing you need to define mavenLocal() repository in a Gradle build. Gradle allows you to constraint the repository only to snapshots.

It is easy to do it with the Gradle Kotlin DSL.

repositories {
    mavenCentral()
    mavenLocal {
        mavenContent {
            snapshotsOnly()
        }
    }
    maven {
        setUrl("https://s01.oss.sonatype.org/content/repositories/snapshots/")
        mavenContent {
            snapshotsOnly()
        }
    }
}

Tags: #gradle #kotlin