@@ -33,30 +33,37 @@ fun Project.configurePublishing() {
3333 }
3434
3535 configurePublications()
36+
37+ if (hasProperty(" signingKey" )) {
38+ configureSigning()
39+ }
40+ if (hasProperty(" sonatypeUsername" )) {
41+ configureNexusPublishing()
42+ }
43+
3644 // https://kotlinlang.org/docs/mpp-publish-lib.html#avoid-duplicate-publications
37- val publicationsFromMainHost = listOf (" jvm" , " js" , " kotlinMultiplatform" )
38- configure<PublishingExtension > {
39- publications {
40- matching { it.name in publicationsFromMainHost }.all {
45+ // Publication with name `kotlinMultiplatform` is for the default artifact.
46+ // `configureNexusPublishing` adds sonatype publication tasks inside `afterEvaluate`.
47+ rootProject.afterEvaluate {
48+ val publicationsFromMainHost = listOf (" jvm" , " js" , " linuxX64" , " kotlinMultiplatform" , " metadata" )
49+ configure<PublishingExtension > {
50+ publications.matching { it.name in publicationsFromMainHost }.all {
4151 val targetPublication = this @all
4252 tasks.withType<AbstractPublishToMaven >()
4353 .matching { it.publication == targetPublication }
4454 .configureEach {
4555 onlyIf {
4656 // main publishing CI job is executed on Linux host
47- DefaultNativePlatform .getCurrentOperatingSystem().isLinux
57+ DefaultNativePlatform .getCurrentOperatingSystem().isLinux.apply {
58+ if (! this ) {
59+ logger.lifecycle(" Publication ${(it as AbstractPublishToMaven ).publication.name} is skipped on current host" )
60+ }
61+ }
4862 }
4963 }
50- }
64+ }
5165 }
5266 }
53-
54- if (hasProperty(" signingKey" )) {
55- configureSigning()
56- }
57- if (hasProperty(" sonatypeUsername" )) {
58- configureNexusPublishing()
59- }
6067}
6168
6269private fun Project.configurePublications () {
0 commit comments