@@ -38,7 +38,6 @@ System.getenv("signing.keyId")?.let { project.ext["signing.keyId"] = it }
3838System .getenv(" signing.password" )?.let { project.ext[" signing.password" ] = it }
3939System .getenv(" signing.secretKeyRingFile" )?.let { project.ext[" signing.secretKeyRingFile" ] = it }
4040
41-
4241tasks.withType<Test > {
4342 this .testLogging {
4443 this .showStandardStreams = true
@@ -173,40 +172,7 @@ kotlin {
173172 listOf (jvm(), js()).map { it.name } + " kotlinMultiplatform"
174173
175174 publishing {
176- publications {
177- matching { it.name in publicationsFromMainHost }.all {
178- val targetPublication = this @all
179- tasks.withType<AbstractPublishToMaven >()
180- .matching { it.publication == targetPublication }
181- .configureEach { onlyIf { findProperty(" isMainHost" ) == " true" } }
182- }
183-
184- val kotlinMultiplatform by getting(MavenPublication ::class ) {
185- artifactId = " spotify-api-kotlin-core"
186- setupPom(artifactId)
187- }
188-
189- /* val metadata by getting(MavenPublication::class) {
190- artifactId = "spotify-api-kotlin-metadata"
191- setupPom(artifactId)
192- }*/
193- }
194-
195- repositories {
196- maven {
197- name = " nexus"
198- val releasesRepoUrl = " https://oss.sonatype.org/service/local/staging/deploy/maven2/"
199- val snapshotsRepoUrl = " https://oss.sonatype.org/content/repositories/snapshots/"
200- url = uri(if (version.toString().endsWith(" SNAPSHOT" )) snapshotsRepoUrl else releasesRepoUrl)
201-
202- credentials {
203- val nexusUsername: String? = System .getenv(" nexus.username" ) ? : if (project.extra.has(" nexusUsername" )) project.extra[" nexusUsername" ] as ? String else null
204- val nexusPassword: String? = System .getenv(" nexus.password" ) ? : if (project.extra.has(" nexusPassword" )) project.extra[" nexusPassword" ] as ? String else null
205- username = nexusUsername
206- password = nexusPassword
207- }
208- }
209- }
175+ registerPublishing()
210176 }
211177
212178 targets {
@@ -330,6 +296,10 @@ kotlin {
330296 }
331297}
332298
299+ publishing {
300+ registerPublishing()
301+ }
302+
333303signing {
334304 if (project.hasProperty(" signing.keyId" )
335305 && project.hasProperty(" signing.password" )
@@ -408,3 +378,32 @@ fun MavenPublication.setupPom(publicationName: String) {
408378 }
409379}
410380
381+ fun PublishingExtension.registerPublishing () {
382+ publications {
383+ val kotlinMultiplatform by getting(MavenPublication ::class ) {
384+ artifactId = " spotify-api-kotlin-core"
385+ setupPom(artifactId)
386+ }
387+
388+ /* val metadata by getting(MavenPublication::class) {
389+ artifactId = "spotify-api-kotlin-metadata"
390+ setupPom(artifactId)
391+ }*/
392+ }
393+
394+ repositories {
395+ maven {
396+ name = " nexus"
397+ val releasesRepoUrl = " https://oss.sonatype.org/service/local/staging/deploy/maven2/"
398+ val snapshotsRepoUrl = " https://oss.sonatype.org/content/repositories/snapshots/"
399+ url = uri(if (version.toString().endsWith(" SNAPSHOT" )) snapshotsRepoUrl else releasesRepoUrl)
400+
401+ credentials {
402+ val nexusUsername: String? = System .getenv(" nexus.username" ) ? : if (project.extra.has(" nexusUsername" )) project.extra[" nexusUsername" ] as ? String else null
403+ val nexusPassword: String? = System .getenv(" nexus.password" ) ? : if (project.extra.has(" nexusPassword" )) project.extra[" nexusPassword" ] as ? String else null
404+ username = nexusUsername
405+ password = nexusPassword
406+ }
407+ }
408+ }
409+ }
0 commit comments