@@ -33,32 +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- // publication with name `kotlinMultiplatform` is for the default artifact
38- // fixme: doesn't work as expected
39- val publicationsFromMainHost = listOf ( " jvm " , " js " , " linuxX64 " , " kotlinMultiplatform " , " metadata " )
40- configure< PublishingExtension > {
41- publications {
42- 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 {
4351 val targetPublication = this @all
4452 tasks.withType<AbstractPublishToMaven >()
4553 .matching { it.publication == targetPublication }
4654 .configureEach {
4755 onlyIf {
4856 // main publishing CI job is executed on Linux host
49- 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+ }
5062 }
5163 }
52- }
64+ }
5365 }
5466 }
55-
56- if (hasProperty(" signingKey" )) {
57- configureSigning()
58- }
59- if (hasProperty(" sonatypeUsername" )) {
60- configureNexusPublishing()
61- }
6267}
6368
6469private fun Project.configurePublications () {
0 commit comments