@@ -60,6 +60,11 @@ open class PublishingConfiguration {
60
60
61
61
class SonatypeConfiguration {
62
62
// 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
63
68
internal var isSelected: Boolean = false
64
69
}
65
70
@@ -318,8 +323,13 @@ private fun Project.verifySonatypeConfiguration(): Boolean {
318
323
return false
319
324
}
320
325
326
+ if (stagingRepositoryId.isNullOrEmpty()) {
327
+ return missing(" staging repository id 'libs.repository.id'. Pass 'auto' for implicit staging" )
328
+ }
329
+
321
330
sonatypeUsername ? : return missing(" username" )
322
331
val password = sonatypePassword ? : return missing(" password" )
332
+
323
333
if (password.startsWith(" credentialsJSON" )) {
324
334
logger.warn(" INFRA: API key secure token was not expanded, publishing is not possible." )
325
335
return false
@@ -422,15 +432,21 @@ private fun Project.configureSigning() {
422
432
423
433
424
434
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
+ }
432
447
}
433
448
}
434
449
450
+ private val Project .stagingRepositoryId: String? get() = propertyOrEnv(" libs.repository.id" )
435
451
private val Project .sonatypeUsername: String? get() = propertyOrEnv(" libs.sonatype.user" )
436
452
private val Project .sonatypePassword: String? get() = propertyOrEnv(" libs.sonatype.password" )
0 commit comments