@@ -33,32 +33,37 @@ fun Project.configurePublishing() {
33
33
}
34
34
35
35
configurePublications()
36
+
37
+ if (hasProperty(" signingKey" )) {
38
+ configureSigning()
39
+ }
40
+ if (hasProperty(" sonatypeUsername" )) {
41
+ configureNexusPublishing()
42
+ }
43
+
36
44
// 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 {
43
51
val targetPublication = this @all
44
52
tasks.withType<AbstractPublishToMaven >()
45
53
.matching { it.publication == targetPublication }
46
54
.configureEach {
47
55
onlyIf {
48
56
// 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
+ }
50
62
}
51
63
}
52
- }
64
+ }
53
65
}
54
66
}
55
-
56
- if (hasProperty(" signingKey" )) {
57
- configureSigning()
58
- }
59
- if (hasProperty(" sonatypeUsername" )) {
60
- configureNexusPublishing()
61
- }
62
67
}
63
68
64
69
private fun Project.configurePublications () {
0 commit comments