Fix KNPE due to publications processing order in Gradle 4.7
A KNPE happened because Gradle 4.7 (but not 4.8+) requested a publication's dependencies before all other publications were created. Issue #KT-27231 Fixed
This commit is contained in:
+1
-1
@@ -21,7 +21,7 @@ import kotlin.test.assertFalse
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class NewMultiplatformIT : BaseGradleIT() {
|
||||
val gradleVersion = GradleVersionRequired.AtLeast("4.8")
|
||||
val gradleVersion = GradleVersionRequired.AtLeast("4.7")
|
||||
|
||||
val nativeHostTargetName = when {
|
||||
HostManager.hostIsMingw -> "mingw64"
|
||||
|
||||
+5
-2
@@ -132,8 +132,7 @@ class KotlinMultiplatformPlugin(
|
||||
publishTask.onlyIf { publishTask.publication != rootPublication || project.multiplatformExtension!!.isGradleMetadataAvailable }
|
||||
}
|
||||
|
||||
// Create separate publications for all publishable targets
|
||||
targets.matching { it.publishable }.all { target ->
|
||||
fun createTargetPublication(target: KotlinTarget) {
|
||||
val variant = target.component as KotlinVariant
|
||||
val name = target.name
|
||||
|
||||
@@ -156,6 +155,10 @@ class KotlinMultiplatformPlugin(
|
||||
it.execute(variantPublication)
|
||||
}
|
||||
}
|
||||
|
||||
// Enforce the order of creating the publications, since the metadata publication is used in the other publications:
|
||||
createTargetPublication(targets.getByName(METADATA_TARGET_NAME))
|
||||
targets.matching { it.publishable && it.name != METADATA_TARGET_NAME }.all(::createTargetPublication)
|
||||
}
|
||||
|
||||
project.components.add(kotlinSoftwareComponent)
|
||||
|
||||
Reference in New Issue
Block a user