Skip to content

Commit 5635f76

Browse files
committed
Support publication to kotlinx/dev space repo
1 parent 29c6360 commit 5635f76

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

buildSrc/src/main/kotlin/Publishing.kt

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,39 @@ import org.gradle.plugins.signing.*
1212
import java.net.*
1313

1414
fun PublishingExtension.mavenRepositoryPublishing(project: Project) {
15+
val isSnapshot = project.isSnapshotRelease()
1516
repositories {
1617
maven {
17-
url = URI("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
18+
url = mavenRepositoryUri(isSnapshot)
1819
credentials {
19-
username = project.getSensitiveProperty("libs.sonatype.user")
20-
password = project.getSensitiveProperty("libs.sonatype.password")
20+
if (isSnapshot) {
21+
username = project.getSensitiveProperty("libs.space.user")
22+
password = project.getSensitiveProperty("libs.space.password")
23+
} else {
24+
username = project.getSensitiveProperty("libs.sonatype.user")
25+
password = project.getSensitiveProperty("libs.sonatype.password")
26+
}
2127
}
2228
}
2329
}
2430
}
2531

32+
private fun Project.isSnapshotRelease(): Boolean {
33+
return version.toString().endsWith("-SNAPSHOT")
34+
}
35+
36+
private fun mavenRepositoryUri(snapshot: Boolean = false): URI {
37+
if (snapshot) {
38+
return URI("https://maven.pkg.jetbrains.space/kotlin/p/kotlinx/dev")
39+
}
40+
val repositoryId: String? = System.getenv("libs.repository.id")
41+
return if (repositoryId == null) {
42+
URI("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
43+
} else {
44+
URI("https://oss.sonatype.org/service/local/staging/deployByRepositoryId/$repositoryId")
45+
}
46+
}
47+
2648
fun Project.signPublicationIfKeyPresent(publication: MavenPublication) {
2749
val keyId = project.getSensitiveProperty("libs.sign.key.id")
2850
val signingKey = project.getSensitiveProperty("libs.sign.key.private")

0 commit comments

Comments
 (0)