Skip to content

Instantly share code, notes, and snippets.

@kubode
Created May 27, 2021 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kubode/d1e7da197f3381b9569336b215c48a9a to your computer and use it in GitHub Desktop.
Save kubode/d1e7da197f3381b9569336b215c48a9a to your computer and use it in GitHub Desktop.
Kotlin DSL extension
repository {
google()
github("kubode/some-repo")
mavenCentral()
}
import java.net.URI
import org.gradle.api.Project
import org.gradle.api.artifacts.dsl.RepositoryHandler
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
import org.gradle.kotlin.dsl.provideDelegate
val RepositoryHandler.github: Project.(repo: String) -> MavenArtifactRepository get() = { repo ->
maven {
url = URI("https://maven.pkg.github.com/$repo")
credentials {
val githubToken: String by project
username = "unused"
password = githubToken
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment