Skip to content

Commit ea9c8f3

Browse files
committed
Missing libs.repository.id property dependency
Improve validation that this property is passed, it is a prerequisite for publishing to sonatype, same as sonatype username and password. Document expected properties.
1 parent af0316c commit ea9c8f3

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

main/resources/teamcity/settings.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ project {
5151
val deploys = platforms.map { deploy(it, deployVersion) }
5252
val deployPublish = deployPublish(deployVersion).apply {
5353
dependsOnSnapshot(buildAll, onFailure = FailureAction.IGNORE)
54+
dependsOnSnapshot(BUILD_CREATE_STAGING_REPO_ABSOLUTE_ID)
5455
deploys.forEach {
5556
dependsOnSnapshot(it)
5657
}
@@ -185,6 +186,7 @@ fun Project.deploy(platform: Platform, configureBuild: BuildType) = buildType("D
185186
param(releaseVersionParameter, "${configureBuild.depParamRefs[releaseVersionParameter]}")
186187
param("bintray-user", bintrayUserName)
187188
password("bintray-key", bintrayToken)
189+
param("env.libs.repository.id", "%dep.$BUILD_CREATE_STAGING_REPO_ABSOLUTE_ID.env.libs.repository.id%")
188190
}
189191

190192
vcs {

main/src/kotlinx/team/infra/Publishing.kt

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ open class PublishingConfiguration {
6060

6161
class SonatypeConfiguration {
6262
// no things to configure here for now
63+
// all information is provided with properties or env. variables with known names:
64+
// - libs.repository.id: sonatype staging repository id, 'auto' to open staging implicitly,
65+
// - libs.sonatype.user: sonatype user name
66+
// - libs.sonatype.password: sonatype password
67+
// - libs.sign.key.id, libs.sign.key.private, libs.sign.passphrase: publication signing information
6368
internal var isSelected: Boolean = false
6469
}
6570

@@ -318,8 +323,13 @@ private fun Project.verifySonatypeConfiguration(): Boolean {
318323
return false
319324
}
320325

326+
if (stagingRepositoryId.isNullOrEmpty()) {
327+
return missing("staging repository id 'libs.repository.id'. Pass 'auto' for implicit staging")
328+
}
329+
321330
sonatypeUsername ?: return missing("username")
322331
val password = sonatypePassword ?: return missing("password")
332+
323333
if (password.startsWith("credentialsJSON")) {
324334
logger.warn("INFRA: API key secure token was not expanded, publishing is not possible.")
325335
return false
@@ -422,15 +432,21 @@ private fun Project.configureSigning() {
422432

423433

424434
private fun Project.sonatypeRepositoryUri(): URI {
425-
val repositoryId: String? = System.getenv("libs.repository.id")
426-
return if (repositoryId == null) {
427-
// Using implicitly created staging, for MPP it's likely a mistake
428-
logger.warn("INFRA: using an implicitly created staging for ${project.rootProject.name}")
429-
URI("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
430-
} else {
431-
URI("https://oss.sonatype.org/service/local/staging/deployByRepositoryId/$repositoryId")
435+
val repositoryId: String? = stagingRepositoryId
436+
return when {
437+
repositoryId.isNullOrEmpty() ->
438+
throw KotlinInfrastructureException("Staging repository id 'libs.repository.id' is not specified.")
439+
repositoryId == "auto" -> {
440+
// Using implicitly created staging, for MPP it's likely a mistake
441+
logger.warn("INFRA: using an implicitly created staging for ${project.rootProject.name}")
442+
URI("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
443+
}
444+
else -> {
445+
URI("https://oss.sonatype.org/service/local/staging/deployByRepositoryId/$repositoryId")
446+
}
432447
}
433448
}
434449

450+
private val Project.stagingRepositoryId: String? get() = propertyOrEnv("libs.repository.id")
435451
private val Project.sonatypeUsername: String? get() = propertyOrEnv("libs.sonatype.user")
436452
private val Project.sonatypePassword: String? get() = propertyOrEnv("libs.sonatype.password")

0 commit comments

Comments
 (0)