File tree Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -12,17 +12,39 @@ import org.gradle.plugins.signing.*
12
12
import java.net.*
13
13
14
14
fun PublishingExtension.mavenRepositoryPublishing (project : Project ) {
15
+ val isSnapshot = project.isSnapshotRelease()
15
16
repositories {
16
17
maven {
17
- url = URI ( " https://oss.sonatype.org/service/local/staging/deploy/maven2/ " )
18
+ url = mavenRepositoryUri(isSnapshot )
18
19
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
+ }
21
27
}
22
28
}
23
29
}
24
30
}
25
31
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
+
26
48
fun Project.signPublicationIfKeyPresent (publication : MavenPublication ) {
27
49
val keyId = project.getSensitiveProperty(" libs.sign.key.id" )
28
50
val signingKey = project.getSensitiveProperty(" libs.sign.key.private" )
You can’t perform that action at this time.
0 commit comments