[Gradle][MPP] CompilationDetails.source: Use .forAll over 'whenEvaluated'
KT-52726
This commit is contained in:
committed by
Space
parent
c6e9216663
commit
5f924518af
+32
-34
@@ -266,8 +266,8 @@ open class DefaultCompilationDetails<T : KotlinCommonOptions>(
|
|||||||
|
|
||||||
override fun source(sourceSet: KotlinSourceSet) {
|
override fun source(sourceSet: KotlinSourceSet) {
|
||||||
if (directlyIncludedKotlinSourceSets.add(sourceSet)) {
|
if (directlyIncludedKotlinSourceSets.add(sourceSet)) {
|
||||||
target.project.whenEvaluated {
|
sourceSet.internal.withDependsOnClosure.forAll { inWithDependsOnClosure ->
|
||||||
addExactSourceSetsEagerly(sourceSet.internal.withDependsOnClosure)
|
addExactSourceSetEagerly(inWithDependsOnClosure)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -280,43 +280,41 @@ open class DefaultCompilationDetails<T : KotlinCommonOptions>(
|
|||||||
addAsCommonSources
|
addAsCommonSources
|
||||||
) { sourceSet.kotlin }
|
) { sourceSet.kotlin }
|
||||||
|
|
||||||
internal fun addExactSourceSetsEagerly(sourceSets: Set<KotlinSourceSet>) {
|
internal fun addExactSourceSetEagerly(sourceSet: KotlinSourceSet) {
|
||||||
with(target.project) {
|
with(target.project) {
|
||||||
//TODO possibly issue with forced instantiation
|
//TODO possibly issue with forced instantiation
|
||||||
sourceSets.forEach { sourceSet ->
|
addSourcesToCompileTask(
|
||||||
addSourcesToCompileTask(
|
sourceSet,
|
||||||
sourceSet,
|
addAsCommonSources = lazy {
|
||||||
addAsCommonSources = lazy {
|
target.project.kotlinExtension.sourceSets.any { otherSourceSet ->
|
||||||
target.project.kotlinExtension.sourceSets.any { otherSourceSet ->
|
sourceSet in otherSourceSet.dependsOn
|
||||||
sourceSet in otherSourceSet.dependsOn
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|
||||||
// Use `forced = false` since `api`, `implementation`, and `compileOnly` may be missing in some cases like
|
|
||||||
// old Java & Android projects:
|
|
||||||
addExtendsFromRelation(compilation.apiConfigurationName, sourceSet.apiConfigurationName, forced = false)
|
|
||||||
addExtendsFromRelation(
|
|
||||||
compilation.implementationConfigurationName,
|
|
||||||
sourceSet.implementationConfigurationName,
|
|
||||||
forced = false
|
|
||||||
)
|
|
||||||
addExtendsFromRelation(compilation.compileOnlyConfigurationName, sourceSet.compileOnlyConfigurationName, forced = false)
|
|
||||||
|
|
||||||
if (compilation is KotlinCompilationToRunnableFiles<*>) {
|
|
||||||
addExtendsFromRelation(compilation.runtimeOnlyConfigurationName, sourceSet.runtimeOnlyConfigurationName, forced = false)
|
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
|
||||||
if (sourceSet.name != defaultSourceSetName) {
|
// Use `forced = false` since `api`, `implementation`, and `compileOnly` may be missing in some cases like
|
||||||
kotlinExtension.sourceSets.findByName(defaultSourceSetName)?.let { defaultSourceSet ->
|
// old Java & Android projects:
|
||||||
// Temporary solution for checking consistency across source sets participating in a compilation that may
|
addExtendsFromRelation(compilation.apiConfigurationName, sourceSet.apiConfigurationName, forced = false)
|
||||||
// not be interconnected with the dependsOn relation: check the settings as if the default source set of
|
addExtendsFromRelation(
|
||||||
// the compilation depends on the one added to the compilation:
|
compilation.implementationConfigurationName,
|
||||||
defaultSourceSetLanguageSettingsChecker.runAllChecks(
|
sourceSet.implementationConfigurationName,
|
||||||
defaultSourceSet,
|
forced = false
|
||||||
sourceSet
|
)
|
||||||
)
|
addExtendsFromRelation(compilation.compileOnlyConfigurationName, sourceSet.compileOnlyConfigurationName, forced = false)
|
||||||
}
|
|
||||||
|
if (compilation is KotlinCompilationToRunnableFiles<*>) {
|
||||||
|
addExtendsFromRelation(compilation.runtimeOnlyConfigurationName, sourceSet.runtimeOnlyConfigurationName, forced = false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sourceSet.name != defaultSourceSetName) {
|
||||||
|
kotlinExtension.sourceSets.findByName(defaultSourceSetName)?.let { defaultSourceSet ->
|
||||||
|
// Temporary solution for checking consistency across source sets participating in a compilation that may
|
||||||
|
// not be interconnected with the dependsOn relation: check the settings as if the default source set of
|
||||||
|
// the compilation depends on the one added to the compilation:
|
||||||
|
defaultSourceSetLanguageSettingsChecker.runAllChecks(
|
||||||
|
defaultSourceSet,
|
||||||
|
sourceSet
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -316,7 +316,7 @@ class KotlinMetadataTargetConfigurator :
|
|||||||
return compilationFactory.create(compilationName).apply {
|
return compilationFactory.create(compilationName).apply {
|
||||||
target.compilations.add(this@apply)
|
target.compilations.add(this@apply)
|
||||||
|
|
||||||
(compilationDetails as DefaultCompilationDetails<*>).addExactSourceSetsEagerly(setOf(sourceSet))
|
(compilationDetails as DefaultCompilationDetails<*>).addExactSourceSetEagerly(sourceSet)
|
||||||
|
|
||||||
configureMetadataDependenciesForCompilation(this@apply)
|
configureMetadataDependenciesForCompilation(this@apply)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user