Skip to content

Commit 0e12731

Browse files
authored
Support a new publication scheme (#305)
1 parent 5252921 commit 0e12731

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import kotlinx.validation.build.addPublishingRepositoryIfPresent
12
import kotlinx.kover.gradle.plugin.dsl.CoverageUnit
23
import kotlinx.validation.build.mavenCentralMetadata
3-
import kotlinx.validation.build.mavenRepositoryPublishing
44
import kotlinx.validation.build.signPublicationIfKeyPresent
55
import org.gradle.api.attributes.TestSuiteType.FUNCTIONAL_TEST
66
import org.jetbrains.dokka.gradle.DokkaTask
@@ -125,8 +125,8 @@ publishing {
125125
create<MavenPublication>("maven") {
126126
from(components["java"])
127127
}
128+
addPublishingRepositoryIfPresent(project)
128129

129-
mavenRepositoryPublishing(project)
130130
mavenCentralMetadata()
131131
}
132132

buildSrc/src/main/kotlin/Publishing.kt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@ import org.gradle.api.publish.maven.*
1111
import org.gradle.plugins.signing.*
1212
import java.net.*
1313

14-
fun PublishingExtension.mavenRepositoryPublishing(project: Project) {
15-
repositories {
16-
maven {
17-
url = URI("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
18-
credentials {
19-
username = project.getSensitiveProperty("libs.sonatype.user")
20-
password = project.getSensitiveProperty("libs.sonatype.password")
14+
// Artifacts are published to an intermediate repo (libs.repo.url) first,
15+
// and then deployed to the central portal.
16+
fun PublishingExtension.addPublishingRepositoryIfPresent(project: Project) {
17+
val repositoryUrl = project.getSensitiveProperty("libs.repo.url")
18+
if (!repositoryUrl.isNullOrBlank()) {
19+
repositories {
20+
maven {
21+
url = URI(repositoryUrl)
22+
credentials {
23+
username = project.getSensitiveProperty("libs.repo.user")
24+
password = project.getSensitiveProperty("libs.repo.password")
25+
}
2126
}
2227
}
2328
}

0 commit comments

Comments
 (0)