Skip to content

Commit e6d4e80

Browse files
committed
Fix publishing config
tasks.withType<AbstractPublishToMaven>().configureEach { ... } runs the lambda when each matching task is created. The nmcp plugin creates publishKotlinFakerBomPublicationToNmcpRepository but doesn't bind the publication property immediately — it's set later. Eagerly calling publication.name during configuration hit the null. Moving it into onlyIf defers it to execution time, when the publication is guaranteed to be set.
1 parent 6e0e212 commit e6d4e80

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

buildSrc/src/main/kotlin/faker-pub-conventions.gradle.kts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,12 @@ pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
187187

188188
// region Letting Faker settings control which publications are enabled
189189
tasks.withType<AbstractPublishToMaven>().configureEach {
190-
val enabled = isPublicationEnabled(publication.name).get()
191-
logger.lifecycle("[task: $path] publishing for ${publication.name} is $enabled")
192-
onlyIf("publishing enabled") { enabled }
190+
onlyIf("publishing enabled") {
191+
val pub = publication ?: return@onlyIf false
192+
val enabled = isPublicationEnabled(pub.name).get()
193+
logger.lifecycle("[task: $path] publishing for ${pub.name} is $enabled")
194+
enabled
195+
}
193196
}
194197

195198
private val fakerSettings = extensions.getByType<BuildSettings>()

0 commit comments

Comments
 (0)