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