KT-40058 NPE from mpp gradle plugin on kotlinx.benchmarks
This commit is contained in:
+11
-3
@@ -52,6 +52,7 @@ interface KotlinTargetConfigurator<KotlinTargetType : KotlinTarget> {
|
|||||||
configureCompilations(target)
|
configureCompilations(target)
|
||||||
defineConfigurationsForTarget(target)
|
defineConfigurationsForTarget(target)
|
||||||
configureArchivesAndComponent(target)
|
configureArchivesAndComponent(target)
|
||||||
|
configureSourceSet(target)
|
||||||
configureBuild(target)
|
configureBuild(target)
|
||||||
configurePlatformSpecificModel(target)
|
configurePlatformSpecificModel(target)
|
||||||
}
|
}
|
||||||
@@ -61,6 +62,7 @@ interface KotlinTargetConfigurator<KotlinTargetType : KotlinTarget> {
|
|||||||
fun defineConfigurationsForTarget(target: KotlinTargetType)
|
fun defineConfigurationsForTarget(target: KotlinTargetType)
|
||||||
fun configureArchivesAndComponent(target: KotlinTargetType)
|
fun configureArchivesAndComponent(target: KotlinTargetType)
|
||||||
fun configureBuild(target: KotlinTargetType)
|
fun configureBuild(target: KotlinTargetType)
|
||||||
|
fun configureSourceSet(target: KotlinTarget)
|
||||||
|
|
||||||
fun configurePlatformSpecificModel(target: KotlinTargetType) = Unit
|
fun configurePlatformSpecificModel(target: KotlinTargetType) = Unit
|
||||||
}
|
}
|
||||||
@@ -106,17 +108,23 @@ abstract class AbstractKotlinTargetConfigurator<KotlinTargetType : KotlinTarget>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun configureCompilationDefaults(target: KotlinTargetType) {
|
override fun configureSourceSet(target: KotlinTarget) {
|
||||||
val project = target.project
|
val project = target.project
|
||||||
|
|
||||||
target.compilations.all { compilation ->
|
target.compilations.all { compilation ->
|
||||||
defineConfigurationsForCompilation(compilation)
|
|
||||||
|
|
||||||
if (createDefaultSourceSets) {
|
if (createDefaultSourceSets) {
|
||||||
project.kotlinExtension.sourceSets.maybeCreate(compilation.defaultSourceSetName).also { sourceSet ->
|
project.kotlinExtension.sourceSets.maybeCreate(compilation.defaultSourceSetName).also { sourceSet ->
|
||||||
compilation.source(sourceSet) // also adds dependencies, requires the configurations for target and source set to exist at this point
|
compilation.source(sourceSet) // also adds dependencies, requires the configurations for target and source set to exist at this point
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun configureCompilationDefaults(target: KotlinTargetType) {
|
||||||
|
val project = target.project
|
||||||
|
|
||||||
|
target.compilations.all { compilation ->
|
||||||
|
defineConfigurationsForCompilation(compilation)
|
||||||
|
|
||||||
if (compilation is KotlinCompilationWithResources) {
|
if (compilation is KotlinCompilationWithResources) {
|
||||||
configureResourceProcessing(compilation, project.files(Callable { compilation.allKotlinSourceSets.map { it.resources } }))
|
configureResourceProcessing(compilation, project.files(Callable { compilation.allKotlinSourceSets.map { it.resources } }))
|
||||||
|
|||||||
+2
-1
@@ -6,6 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.gradle.plugin.mpp
|
package org.jetbrains.kotlin.gradle.plugin.mpp
|
||||||
|
|
||||||
import groovy.lang.Closure
|
import groovy.lang.Closure
|
||||||
|
import org.gradle.api.GradleException
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.Task
|
import org.gradle.api.Task
|
||||||
import org.gradle.api.attributes.AttributeContainer
|
import org.gradle.api.attributes.AttributeContainer
|
||||||
@@ -53,7 +54,7 @@ abstract class AbstractKotlinCompilation<T : KotlinCommonOptions>(
|
|||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
override val compileKotlinTaskProvider: TaskProvider<out KotlinCompile<T>>
|
override val compileKotlinTaskProvider: TaskProvider<out KotlinCompile<T>>
|
||||||
get() = target.project.locateTask(compileKotlinTaskName)!!
|
get() = target.project.locateTask(compileKotlinTaskName) ?: throw GradleException("Couldn't locate task $compileKotlinTaskName")
|
||||||
|
|
||||||
// Don't declare this property in the constructor to avoid NPE
|
// Don't declare this property in the constructor to avoid NPE
|
||||||
// when an overriding property of a subclass is accessed instead.
|
// when an overriding property of a subclass is accessed instead.
|
||||||
|
|||||||
Reference in New Issue
Block a user