Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 5 additions & 30 deletions buildSrc/src/main/kotlin/Publishing.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,38 +43,13 @@ fun MavenPom.configureMavenCentralMetadata(project: Project) {
}
}

/**
* 'libs.space.pub' is a dev option that is set on our CI in order to publish
* dev build into 'https://maven.pkg.jetbrains.space/public/p/kotlinx-coroutines/maven' Maven repository.
* In order to use it, pass the corresponding ENV to the TC 'Deploy' task.
*/
private val spacePublicationEnabled = System.getenv("libs.space.pub")?.equals("true") ?: false

fun mavenRepositoryUri(): URI {
if (spacePublicationEnabled) {
return URI("https://maven.pkg.jetbrains.space/public/p/kotlinx-coroutines/maven")
}

val repositoryId: String? = System.getenv("libs.repository.id")
return if (repositoryId == null) {
URI("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
} else {
URI("https://oss.sonatype.org/service/local/staging/deployByRepositoryId/$repositoryId")
}
}

fun configureMavenPublication(rh: RepositoryHandler, project: Project) {
rh.maven {
url = mavenRepositoryUri()
credentials {
if (spacePublicationEnabled) {
// Configure space credentials
username = project.getSensitiveProperty("libs.space.user")
password = project.getSensitiveProperty("libs.space.password")
} else {
// Configure sonatype credentials
username = project.getSensitiveProperty("libs.sonatype.user")
password = project.getSensitiveProperty("libs.sonatype.password")
setUrl(project.getSensitiveProperty("libs.repo.url") ?: "file://${project.rootProject.layout.buildDirectory.dir("repo").get().asFile}")
if (url.scheme != "file") {
credentials {
username = project.getSensitiveProperty("libs.repo.user")
password = project.getSensitiveProperty("libs.repo.password")
}
}
}
Expand Down