[kpm] Introduce Kpm* naming convention (1/2)

All Kpm owned entities shall be disambiguated by using the `Kpm` prefix
E.g. MyEntity has to be called KpmMyEntity and a subclass is called
KpmSpecialMyEntity
This commit is contained in:
sebastian.sellmair
2022-05-24 12:00:07 +02:00
committed by Space
parent 49175f83aa
commit 71677ad455
127 changed files with 1095 additions and 1094 deletions
@@ -8,23 +8,7 @@ package org.jetbrains.kotlin.project.model
// TODO ensure that resolvers are pluggable + custom dependency kinds (& result kinds?)
// TODO think about state management: unresolved -> (known dependency graph?) ... -> completely resolved
// it seems to be important to learn whether or not the model is final
interface ModuleDependencyResolver {
fun resolveDependency(requestingModule: KotlinModule, moduleDependency: KotlinModuleDependency): KotlinModule?
interface KpmModuleDependencyResolver {
fun resolveDependency(requestingModule: KpmModule, moduleDependency: KpmModuleDependency): KpmModule?
}
interface KotlinDependencyGraphResolver {
fun resolveDependencyGraph(requestingModule: KotlinModule): DependencyGraphResolution
}
sealed class DependencyGraphResolution(open val requestingModule: KotlinModule) {
class Unknown(requestingModule: KotlinModule) : DependencyGraphResolution(requestingModule)
open class DependencyGraph(requestingModule: KotlinModule, open val root: DependencyGraphNode): DependencyGraphResolution(requestingModule)
}
// TODO: should this be a single graph for all dependency scopes as well, not just for all fragments?
open class DependencyGraphNode(
open val module: KotlinModule,
open val dependenciesByFragment: Map<KotlinModuleFragment, Iterable<DependencyGraphNode>>
) {
override fun toString(): String = "node ${module}"
}
@@ -5,53 +5,25 @@
package org.jetbrains.kotlin.project.model
import java.io.Serializable
sealed class KotlinModuleIdentifier(open val moduleClassifier: String?): Serializable
// TODO consider id: Any, to allow IDs with custom equality?
data class LocalModuleIdentifier(
val buildId: String,
val projectId: String,
override val moduleClassifier: String?
) : KotlinModuleIdentifier(moduleClassifier) {
companion object {
private const val SINGLE_BUILD_ID = ":"
}
override fun toString(): String =
"project '$projectId'" +
moduleClassifier?.let { " / $it" }.orEmpty() +
buildId.takeIf { it != SINGLE_BUILD_ID }?.let { "(build '$it')" }.orEmpty()
}
data class MavenModuleIdentifier(
val group: String,
val name: String,
override val moduleClassifier: String?
) : KotlinModuleIdentifier(moduleClassifier) {
override fun toString(): String = "$group:$name" + moduleClassifier?.let { " / $it" }.orEmpty()
}
// TODO Gradle allows having multiple capabilities in a published module, we need to figure out how we can include them in the module IDs
interface KotlinModule {
val moduleIdentifier: KotlinModuleIdentifier
interface KpmModule {
val moduleIdentifier: KpmModuleIdentifier
val fragments: Iterable<KotlinModuleFragment>
val fragments: Iterable<KpmFragment>
val variants: Iterable<KotlinModuleVariant>
get() = fragments.filterIsInstance<KotlinModuleVariant>()
val variants: Iterable<KpmVariant>
get() = fragments.filterIsInstance<KpmVariant>()
val plugins: Iterable<KpmCompilerPlugin>
// TODO: isSynthetic?
}
open class BasicKotlinModule(
override val moduleIdentifier: KotlinModuleIdentifier
) : KotlinModule {
override val fragments = mutableListOf<BasicKotlinModuleFragment>()
open class KpmBasicModule(
override val moduleIdentifier: KpmModuleIdentifier
) : KpmModule {
override val fragments = mutableListOf<KpmBasicFragment>()
override val plugins = mutableListOf<KpmCompilerPlugin>()
@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.project.model
data class KotlinModuleDependency(val moduleIdentifier: KotlinModuleIdentifier) {
data class KpmModuleDependency(val moduleIdentifier: KpmModuleIdentifier) {
override fun toString(): String = "dependency $moduleIdentifier"
}
@@ -10,28 +10,31 @@ import org.jetbrains.kotlin.tooling.core.closure
import org.jetbrains.kotlin.tooling.core.withClosure
import java.io.File
interface KotlinModuleFragment {
val containingModule: KotlinModule
interface KpmFragment {
val containingModule: KpmModule
val fragmentName: String
val directRefinesDependencies: Iterable<KotlinModuleFragment>
val languageSettings: LanguageSettings?
// TODO: scopes
val declaredModuleDependencies: Iterable<KotlinModuleDependency>
// TODO: should this be source roots or source files?
val kotlinSourceRoots: Iterable<File>
// TODO: scopes
val declaredModuleDependencies: Iterable<KpmModuleDependency>
val declaredRefinesDependencies: Iterable<KpmFragment>
val refinesClosure: Set<KpmFragment>
get() = this.closure { it.declaredRefinesDependencies }
val withRefinesClosure: Set<KpmFragment>
get() = this.withClosure { it.declaredRefinesDependencies }
companion object
}
interface KotlinModuleVariant : KotlinModuleFragment {
val variantAttributes: Map<KotlinAttributeKey, String>
}
val KotlinModuleFragment.fragmentAttributeSets: Map<KotlinAttributeKey, Set<String>>
val KpmFragment.fragmentAttributeSets: Map<KotlinAttributeKey, Set<String>>
get() = mutableMapOf<KotlinAttributeKey, MutableSet<String>>().apply {
containingModule.variantsContainingFragment(this@fragmentAttributeSets).forEach { variant ->
variant.variantAttributes.forEach { (attribute, value) ->
@@ -40,37 +43,20 @@ val KotlinModuleFragment.fragmentAttributeSets: Map<KotlinAttributeKey, Set<Stri
}
}
val KotlinModuleFragment.refinesClosure: Set<KotlinModuleFragment>
get() = this.closure { it.directRefinesDependencies }
val KpmVariant.platform get() = variantAttributes[KotlinPlatformTypeAttribute]
val KotlinModuleFragment.withRefinesClosure: Set<KotlinModuleFragment>
get() = this.withClosure { it.directRefinesDependencies }
val KotlinModuleVariant.platform get() = variantAttributes[KotlinPlatformTypeAttribute]
open class BasicKotlinModuleFragment(
override val containingModule: KotlinModule,
open class KpmBasicFragment(
override val containingModule: KpmModule,
override val fragmentName: String,
override val languageSettings: LanguageSettings? = null
) : KotlinModuleFragment {
) : KpmFragment {
override val directRefinesDependencies: MutableSet<BasicKotlinModuleFragment> = mutableSetOf()
override val declaredRefinesDependencies: MutableSet<KpmBasicFragment> = mutableSetOf()
override val declaredModuleDependencies: MutableSet<KotlinModuleDependency> = mutableSetOf()
override val declaredModuleDependencies: MutableSet<KpmModuleDependency> = mutableSetOf()
override var kotlinSourceRoots: Iterable<File> = emptyList()
override fun toString(): String = "fragment $fragmentName"
}
class BasicKotlinModuleVariant(
containingModule: KotlinModule,
fragmentName: String,
languageSettings: LanguageSettings? = null
) : BasicKotlinModuleFragment(
containingModule,
fragmentName,
languageSettings
), KotlinModuleVariant {
override val variantAttributes: MutableMap<KotlinAttributeKey, String> = mutableMapOf()
override fun toString(): String = "variant $fragmentName"
}
@@ -18,19 +18,19 @@ interface KpmCompilerPlugin {
* Returns [PluginData] when applicable for [fragment] compilation
* Returns [null] if not applicable
*/
fun forMetadataCompilation(fragment: KotlinModuleFragment): PluginData?
fun forMetadataCompilation(fragment: KpmFragment): PluginData?
/**
* Returns [PluginData] when applicable for [fragment] compilation
* Returns [null] if not applicable
*/
fun forNativeMetadataCompilation(fragment: KotlinModuleFragment): PluginData?
fun forNativeMetadataCompilation(fragment: KpmFragment): PluginData?
/**
* Returns [PluginData] when applicable for [variant] compilation
* Returns [null] if not applicable
*/
fun forPlatformCompilation(variant: KotlinModuleVariant): PluginData?
fun forPlatformCompilation(variant: KpmVariant): PluginData?
}
/**
@@ -79,17 +79,17 @@ data class FilesOption(
// TODO: It should be part of "Compilation Process": KotlinModule.compilationRequestFor(METADATA | PLATFORM) -> CompilationRequest
// But there is no such thing at the moment :)
fun KotlinModuleFragment.metadataCompilationPluginData(): List<PluginData> =
fun KpmFragment.metadataCompilationPluginData(): List<PluginData> =
containingModule
.plugins
.mapNotNull { plugin -> plugin.forMetadataCompilation(this) }
fun KotlinModuleFragment.nativeMetadataCompilationPluginData(): List<PluginData> =
fun KpmFragment.nativeMetadataCompilationPluginData(): List<PluginData> =
containingModule
.plugins
.mapNotNull { plugin -> plugin.forNativeMetadataCompilation(this) }
fun KotlinModuleVariant.platformCompilationPluginData(): List<PluginData> =
fun KpmVariant.platformCompilationPluginData(): List<PluginData> =
containingModule
.plugins
.mapNotNull { plugin -> plugin.forPlatformCompilation(this) }
@@ -108,11 +108,11 @@ abstract class BasicKpmCompilerPlugin : KpmCompilerPlugin {
protected abstract val pluginOptions: List<PluginOption>
override fun forMetadataCompilation(fragment: KotlinModuleFragment) = pluginDataOrNull(commonPluginArtifact())
override fun forMetadataCompilation(fragment: KpmFragment) = pluginDataOrNull(commonPluginArtifact())
override fun forNativeMetadataCompilation(fragment: KotlinModuleFragment) = pluginDataOrNull(nativePluginArtifact())
override fun forNativeMetadataCompilation(fragment: KpmFragment) = pluginDataOrNull(nativePluginArtifact())
override fun forPlatformCompilation(variant: KotlinModuleVariant) =
override fun forPlatformCompilation(variant: KpmVariant) =
when (variant.platform) {
KotlinPlatformTypeAttribute.NATIVE -> nativePluginArtifact()
else -> commonPluginArtifact()
@@ -0,0 +1,25 @@
/*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.project.model
interface KpmDependencyGraphResolver {
fun resolveDependencyGraph(requestingModule: KpmModule): KpmDependencyGraphResolution
}
sealed class KpmDependencyGraphResolution(open val requestingModule: KpmModule) {
class Unknown(requestingModule: KpmModule) : KpmDependencyGraphResolution(requestingModule)
open class KpmDependencyGraph(
requestingModule: KpmModule, open val root: KpmDependencyGraphNode
) : KpmDependencyGraphResolution(requestingModule)
}
// TODO: should this be a single graph for all dependency scopes as well, not just for all fragments?
open class KpmDependencyGraphNode(
open val module: KpmModule,
open val dependenciesByFragment: Map<KpmFragment, Iterable<KpmDependencyGraphNode>>
) {
override fun toString(): String = "node ${module}"
}
@@ -0,0 +1,33 @@
/*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.project.model
import java.io.Serializable
sealed class KpmModuleIdentifier(open val moduleClassifier: String?) : Serializable
data class KpmLocalModuleIdentifier(
val buildId: String,
val projectId: String,
override val moduleClassifier: String?
) : KpmModuleIdentifier(moduleClassifier) {
companion object {
private const val SINGLE_BUILD_ID = ":"
}
override fun toString(): String =
"project '$projectId'" +
moduleClassifier?.let { " / $it" }.orEmpty() +
buildId.takeIf { it != SINGLE_BUILD_ID }?.let { "(build '$it')" }.orEmpty()
}
data class KpmMavenModuleIdentifier(
val group: String,
val name: String,
override val moduleClassifier: String?
) : KpmModuleIdentifier(moduleClassifier) {
override fun toString(): String = "$group:$name" + moduleClassifier?.let { " / $it" }.orEmpty()
}
@@ -0,0 +1,19 @@
/*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.project.model
interface KpmVariant : KpmFragment {
val variantAttributes: Map<KotlinAttributeKey, String>
}
class KpmBasicVariant(
containingModule: KpmModule, fragmentName: String, languageSettings: LanguageSettings? = null
) : KpmBasicFragment(
containingModule, fragmentName, languageSettings
), KpmVariant {
override val variantAttributes: MutableMap<KotlinAttributeKey, String> = mutableMapOf()
override fun toString(): String = "variant $fragmentName"
}
@@ -10,6 +10,5 @@ interface LanguageSettings {
val apiVersion: String?
val progressiveMode: Boolean
val enabledLanguageFeatures: Set<String>
val optInAnnotationsInUse: Set<String>
}
@@ -9,24 +9,24 @@ import org.jetbrains.kotlin.project.model.utils.variantsContainingFragment
interface ModuleFragmentsResolver {
fun getChosenFragments(
requestingFragment: KotlinModuleFragment,
dependencyModule: KotlinModule
requestingFragment: KpmFragment,
dependencyModule: KpmModule
): FragmentResolution
}
sealed class FragmentResolution(val requestingFragment: KotlinModuleFragment, val dependencyModule: KotlinModule) {
sealed class FragmentResolution(val requestingFragment: KpmFragment, val dependencyModule: KpmModule) {
class ChosenFragments(
requestingFragment: KotlinModuleFragment,
dependencyModule: KotlinModule,
val visibleFragments: Iterable<KotlinModuleFragment>,
requestingFragment: KpmFragment,
dependencyModule: KpmModule,
val visibleFragments: Iterable<KpmFragment>,
val variantResolutions: Iterable<VariantResolution>
) : FragmentResolution(requestingFragment, dependencyModule)
class NotRequested(requestingFragment: KotlinModuleFragment, dependencyModule: KotlinModule) :
class NotRequested(requestingFragment: KpmFragment, dependencyModule: KpmModule) :
FragmentResolution(requestingFragment, dependencyModule)
// TODO: think about restricting calls with the type system to avoid partial functions in resolvers?
class Unknown(requestingFragment: KotlinModuleFragment, dependencyModule: KotlinModule) :
class Unknown(requestingFragment: KpmFragment, dependencyModule: KpmModule) :
FragmentResolution(requestingFragment, dependencyModule)
}
@@ -34,8 +34,8 @@ class DefaultModuleFragmentsResolver(
private val variantResolver: ModuleVariantResolver
) : ModuleFragmentsResolver {
override fun getChosenFragments(
requestingFragment: KotlinModuleFragment,
dependencyModule: KotlinModule
requestingFragment: KpmFragment,
dependencyModule: KpmModule
): FragmentResolution {
val dependingModule = requestingFragment.containingModule
val containingVariants = dependingModule.variantsContainingFragment(requestingFragment)
@@ -55,7 +55,7 @@ class DefaultModuleFragmentsResolver(
}
val result = if (chosenFragments.isEmpty())
emptyList<KotlinModuleFragment>()
emptyList<KpmFragment>()
else chosenFragments
// Note this emulates the existing behavior that is lenient wrt to unresolved modules, but gives imprecise results. TODO revisit
.filter { it.isNotEmpty() }
@@ -20,7 +20,7 @@ interface ModuleVariantResolver {
* In this case it should return [VariantResolution.Unknown], and the caller (which might be an aggregating [ModuleVariantResolver])
* may consult other sources to get the variant match.
*/
fun getChosenVariant(requestingVariant: KotlinModuleVariant, dependencyModule: KotlinModule): VariantResolution
fun getChosenVariant(requestingVariant: KpmVariant, dependencyModule: KpmModule): VariantResolution
}
/**
@@ -28,14 +28,14 @@ interface ModuleVariantResolver {
* usually done by some [ModuleVariantResolver].
*/
sealed class VariantResolution(
val requestingVariant: KotlinModuleVariant,
val dependencyModule: KotlinModule
val requestingVariant: KpmVariant,
val dependencyModule: KpmModule
) {
companion object {
fun fromMatchingVariants(
requestingVariant: KotlinModuleVariant,
dependencyModule: KotlinModule,
matchingVariants: Collection<KotlinModuleVariant>
requestingVariant: KpmVariant,
dependencyModule: KpmModule,
matchingVariants: Collection<KpmVariant>
) = when (matchingVariants.size) {
0 -> NoVariantMatch(requestingVariant, dependencyModule)
1 -> VariantMatch(requestingVariant, dependencyModule, matchingVariants.single())
@@ -55,20 +55,20 @@ sealed class VariantResolution(
* The resolver decided that the [chosenVariant] is the best variant match.
*/
class VariantMatch(
requestingVariant: KotlinModuleVariant,
dependencyModule: KotlinModule,
val chosenVariant: KotlinModuleVariant
requestingVariant: KpmVariant,
dependencyModule: KpmModule,
val chosenVariant: KpmVariant
) : VariantResolution(requestingVariant, dependencyModule)
// TODO: think about restricting calls with the type system to avoid partial functions in resolvers?
class Unknown(requestingVariant: KotlinModuleVariant, dependencyModule: KotlinModule) :
class Unknown(requestingVariant: KpmVariant, dependencyModule: KpmModule) :
VariantResolution(requestingVariant, dependencyModule)
/**
* Returned when the resolver detects that the [requestingVariant] does not depend on [dependencyModule] and therefore should not get
* any variant of that module at all.
*/
class NotRequested(requestingVariant: KotlinModuleVariant, dependencyModule: KotlinModule) :
class NotRequested(requestingVariant: KpmVariant, dependencyModule: KpmModule) :
VariantResolution(requestingVariant, dependencyModule)
/**
@@ -76,8 +76,8 @@ sealed class VariantResolution(
* done externally and the external system did not provide any details of the failure.
*/
class NoVariantMatch(
requestingVariant: KotlinModuleVariant,
dependencyModule: KotlinModule
requestingVariant: KpmVariant,
dependencyModule: KpmModule
) : VariantResolution(requestingVariant, dependencyModule)
/**
@@ -85,8 +85,8 @@ sealed class VariantResolution(
* best match for the [requestingVariant].
*/
class AmbiguousVariants(
requestingVariant: KotlinModuleVariant,
dependencyModule: KotlinModule,
val matchingVariants: Iterable<KotlinModuleVariant>
requestingVariant: KpmVariant,
dependencyModule: KpmModule,
val matchingVariants: Iterable<KpmVariant>
) : VariantResolution(requestingVariant, dependencyModule)
}
}
@@ -5,17 +5,16 @@
package org.jetbrains.kotlin.project.model.utils
import org.jetbrains.kotlin.project.model.KotlinModule
import org.jetbrains.kotlin.project.model.KotlinModuleFragment
import org.jetbrains.kotlin.project.model.KotlinModuleVariant
import org.jetbrains.kotlin.project.model.withRefinesClosure
import org.jetbrains.kotlin.project.model.KpmModule
import org.jetbrains.kotlin.project.model.KpmFragment
import org.jetbrains.kotlin.project.model.KpmVariant
import org.jetbrains.kotlin.tooling.core.closure
fun KotlinModule.variantsContainingFragment(fragment: KotlinModuleFragment): Iterable<KotlinModuleVariant> =
fun KpmModule.variantsContainingFragment(fragment: KpmFragment): Iterable<KpmVariant> =
variants.filter { variant -> fragment in variant.withRefinesClosure }
fun KotlinModule.findRefiningFragments(fragment: KotlinModuleFragment): Iterable<KotlinModuleFragment> {
fun KpmModule.findRefiningFragments(fragment: KpmFragment): Iterable<KpmFragment> {
return fragment.closure { seedFragment ->
fragments.filter { otherFragment -> seedFragment in otherFragment.directRefinesDependencies }
fragments.filter { otherFragment -> seedFragment in otherFragment.declaredRefinesDependencies }
}
}
@@ -6,7 +6,7 @@
package org.jetbrains.kotlin.project.model
class MatchVariantsByExactAttributes : ModuleVariantResolver {
override fun getChosenVariant(requestingVariant: KotlinModuleVariant, dependencyModule: KotlinModule): VariantResolution {
override fun getChosenVariant(requestingVariant: KpmVariant, dependencyModule: KpmModule): VariantResolution {
val candidates = dependencyModule.variants
return candidates.filter { candidate ->
candidate.variantAttributes.all { (attributeKey, candidateValue) ->
@@ -15,4 +15,4 @@ class MatchVariantsByExactAttributes : ModuleVariantResolver {
}
}.let { VariantResolution.fromMatchingVariants(requestingVariant, dependencyModule, it) }
}
}
}
@@ -5,57 +5,57 @@
package org.jetbrains.kotlin.project.model
fun module(name: String, classifier: String? = null) = BasicKotlinModule(LocalModuleIdentifier("current", name, classifier))
fun module(name: String, classifier: String? = null) = KpmBasicModule(KpmLocalModuleIdentifier("current", name, classifier))
fun BasicKotlinModule.fragment(vararg nameParts: String): BasicKotlinModuleFragment =
fun KpmBasicModule.fragment(vararg nameParts: String): KpmBasicFragment =
fragment(nameParts.drop(1).joinToString("", nameParts.first()) { it.capitalize() })
fun BasicKotlinModule.fragment(name: String): BasicKotlinModuleFragment =
fragments.firstOrNull { it.fragmentName == name } ?: BasicKotlinModuleFragment(this, name).also { fragments.add(it) }
fun KpmBasicModule.fragment(name: String): KpmBasicFragment =
fragments.firstOrNull { it.fragmentName == name } ?: KpmBasicFragment(this, name).also { fragments.add(it) }
fun BasicKotlinModule.variant(vararg nameParts: String): BasicKotlinModuleVariant =
fun KpmBasicModule.variant(vararg nameParts: String): KpmBasicVariant =
variant(nameParts.drop(1).joinToString("", nameParts.first()) { it.capitalize() })
fun BasicKotlinModule.variant(name: String): BasicKotlinModuleVariant =
fun KpmBasicModule.variant(name: String): KpmBasicVariant =
fragments.firstOrNull { it.fragmentName == name }
?.let { it as? BasicKotlinModuleVariant ?: error("$name is not a variant") }
?: BasicKotlinModuleVariant(this, name).also { fragments.add(it) }
?.let { it as? KpmBasicVariant ?: error("$name is not a variant") }
?: KpmBasicVariant(this, name).also { fragments.add(it) }
fun KotlinModuleIdentifier.equalsWithoutClassifier(other: KotlinModuleIdentifier) = when (this) {
is LocalModuleIdentifier -> other is LocalModuleIdentifier &&
LocalModuleIdentifier(buildId, projectId, null) == LocalModuleIdentifier(other.buildId, other.projectId, null)
is MavenModuleIdentifier -> other is MavenModuleIdentifier &&
MavenModuleIdentifier(group, name, null) == MavenModuleIdentifier(other.group, other.name, null)
fun KpmModuleIdentifier.equalsWithoutClassifier(other: KpmModuleIdentifier) = when (this) {
is KpmLocalModuleIdentifier -> other is KpmLocalModuleIdentifier &&
KpmLocalModuleIdentifier(buildId, projectId, null) == KpmLocalModuleIdentifier(other.buildId, other.projectId, null)
is KpmMavenModuleIdentifier -> other is KpmMavenModuleIdentifier &&
KpmMavenModuleIdentifier(group, name, null) == KpmMavenModuleIdentifier(other.group, other.name, null)
else -> error("can't check equality yet")
}
fun BasicKotlinModuleFragment.depends(module: BasicKotlinModule) {
this.declaredModuleDependencies += KotlinModuleDependency(module.moduleIdentifier)
fun KpmBasicFragment.depends(module: KpmBasicModule) {
this.declaredModuleDependencies += KpmModuleDependency(module.moduleIdentifier)
}
fun BasicKotlinModuleFragment.refinedBy(fragment: BasicKotlinModuleFragment) {
fun KpmBasicFragment.refinedBy(fragment: KpmBasicFragment) {
fragment.refines(this)
}
fun BasicKotlinModuleFragment.refines(fragment: BasicKotlinModuleFragment) {
fun KpmBasicFragment.refines(fragment: KpmBasicFragment) {
require(fragment.containingModule == containingModule)
directRefinesDependencies.add(fragment)
declaredRefinesDependencies.add(fragment)
}
// ---
internal data class ModuleBundle(val modules: List<BasicKotlinModule>) {
val main: BasicKotlinModule
internal data class ModuleBundle(val modules: List<KpmBasicModule>) {
val main: KpmBasicModule
get() = modules.single { it.moduleIdentifier.moduleClassifier == null }
operator fun get(modulePurpose: String): BasicKotlinModule = when (modulePurpose) {
operator fun get(modulePurpose: String): KpmBasicModule = when (modulePurpose) {
"main" -> main
else -> modules.single { it.moduleIdentifier.moduleClassifier == modulePurpose }
}
}
internal fun simpleModuleBundle(name: String): ModuleBundle {
fun createModule(purpose: String): BasicKotlinModule =
fun createModule(purpose: String): KpmBasicModule =
module(name, purpose.takeIf { it != "main" }).apply {
val common = fragment("common")
@@ -90,4 +90,4 @@ internal fun simpleModuleBundle(name: String): ModuleBundle {
test.fragment("common").depends(main)
return ModuleBundle(listOf(main, test))
}
}