ModuleOrigin -> ModuleIdentifier
This commit is contained in:
committed by
TeamCityServer
parent
66b8a444c2
commit
7103aa3100
@@ -5,10 +5,15 @@
|
||||
|
||||
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(moduleDependency: ModuleDependency): KotlinModule?
|
||||
}
|
||||
|
||||
// TODO merge with ModuleDependencyResolver?
|
||||
// Semantically, they are close and may use shared caches and other shared state in the implementations
|
||||
interface DependencyDiscovery {
|
||||
// TODO return dependency graph rather than just iterable?
|
||||
// TODO make this a partial function, too
|
||||
|
||||
@@ -5,13 +5,26 @@
|
||||
|
||||
package org.jetbrains.kotlin.project.model
|
||||
|
||||
sealed class ModuleOrigin
|
||||
data class LocalBuild(val buildId: String) : ModuleOrigin() // TODO add project ID?
|
||||
data class ExternalOrigin(val dependencyIdParts: List<String>) : ModuleOrigin()
|
||||
// TODO sealed with an abstract subclass? this will make exhaustive checks work
|
||||
open class ModuleIdentifier
|
||||
|
||||
// TODO consider id: Any, to allow IDs with custom equality?
|
||||
data class LocalModuleIdentifier(val buildId: String, val projectId: String) : ModuleIdentifier() {
|
||||
companion object {
|
||||
private const val SINGLE_BUILD_ID = ":"
|
||||
}
|
||||
|
||||
override fun toString(): String = "project '$projectId'" + buildId.takeIf { it != SINGLE_BUILD_ID }?.let { "(build '$it')" }.orEmpty()
|
||||
}
|
||||
|
||||
data class MavenModuleIdentifier(val group: String, val name: String) : ModuleIdentifier() {
|
||||
override fun toString(): String = "$group:$name"
|
||||
}
|
||||
|
||||
// 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 moduleName: String
|
||||
val moduleOrigin: ModuleOrigin
|
||||
val moduleIdentifier: ModuleIdentifier
|
||||
|
||||
val fragments: Iterable<KotlinModuleFragment>
|
||||
|
||||
@@ -20,10 +33,9 @@ interface KotlinModule {
|
||||
}
|
||||
|
||||
class BasicKotlinModule(
|
||||
override val moduleName: String,
|
||||
override val moduleOrigin: ModuleOrigin
|
||||
override val moduleIdentifier: ModuleIdentifier
|
||||
) : KotlinModule {
|
||||
override val fragments = mutableListOf<BasicKotlinModuleFragment>()
|
||||
|
||||
override fun toString(): String = "module '$moduleName'"
|
||||
override fun toString(): String = "module $moduleIdentifier"
|
||||
}
|
||||
@@ -5,13 +5,11 @@
|
||||
|
||||
package org.jetbrains.kotlin.project.model
|
||||
|
||||
sealed class ModuleDependency(open val moduleOrigin: ModuleOrigin)
|
||||
|
||||
data class ExternalModuleDependency(override val moduleOrigin: ExternalOrigin) : ModuleDependency(moduleOrigin) {
|
||||
override fun toString() = "external dependency ${moduleOrigin.dependencyIdParts.joinToString(":")}"
|
||||
data class ModuleDependency(val moduleIdentifier: ModuleIdentifier) {
|
||||
override fun toString(): String = "dependency $moduleIdentifier"
|
||||
}
|
||||
|
||||
data class LocalModuleDependency(override val moduleOrigin: LocalBuild, val moduleName: String) :
|
||||
ModuleDependency(moduleOrigin) {
|
||||
override fun toString() = "local module $moduleName (build ${moduleOrigin.buildId})"
|
||||
}
|
||||
/**
|
||||
* TODO other kinds of dependencies: non-Kotlin: cinterop, CocoaPods, NPM dependencies?
|
||||
* support with different moduleIdentifiers? Introduce other kinds of dependencies than ModuleDependency?
|
||||
*/
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.project.model
|
||||
|
||||
fun module(name: String) = BasicKotlinModule(name, LocalBuild("current"))
|
||||
fun module(name: String) = BasicKotlinModule(LocalModuleIdentifier("current", name))
|
||||
|
||||
fun BasicKotlinModule.fragment(vararg nameParts: String): BasicKotlinModuleFragment =
|
||||
fragment(nameParts.drop(1).joinToString("", nameParts.first()) { it.capitalize() })
|
||||
|
||||
Reference in New Issue
Block a user