MPP: Allow 'implements' relation only within the same Gradle project
Also allow COMMON modules on the "implementer" side
This commit is contained in:
+7
-2
@@ -28,6 +28,9 @@ import org.jetbrains.kotlin.resolve.TargetPlatform
|
||||
val Module.isNewMPPModule: Boolean
|
||||
get() = KotlinFacet.get(this)?.configuration?.settings?.kind?.isNewMPP ?: false
|
||||
|
||||
val Module.externalProjectId: String
|
||||
get() = KotlinFacet.get(this)?.configuration?.settings?.externalProjectId ?: ""
|
||||
|
||||
val Module.isMPPModule: Boolean
|
||||
get() {
|
||||
val settings = KotlinFacet.get(this)?.configuration?.settings ?: return false
|
||||
@@ -42,7 +45,7 @@ val Module.implementingModules: List<Module>
|
||||
CachedValueProvider.Result(
|
||||
if (isNewMPPModule) {
|
||||
moduleManager.getModuleDependentModules(this).filter {
|
||||
it.isNewMPPModule && it.platform !is CommonIdePlatformKind.Platform
|
||||
it.isNewMPPModule && it.externalProjectId == externalProjectId
|
||||
}
|
||||
} else {
|
||||
moduleManager.modules.filter { name in it.findOldFashionedImplementedModuleNames() }
|
||||
@@ -56,7 +59,9 @@ val Module.implementedModules: List<Module>
|
||||
CachedValueProvider {
|
||||
CachedValueProvider.Result(
|
||||
if (isNewMPPModule) {
|
||||
rootManager.dependencies.filter { it.isNewMPPModule && it.platform is CommonIdePlatformKind.Platform }
|
||||
rootManager.dependencies.filter {
|
||||
it.isNewMPPModule && it.platform is CommonIdePlatformKind.Platform && it.externalProjectId == externalProjectId
|
||||
}
|
||||
} else {
|
||||
val modelsProvider = IdeModelsProviderImpl(project)
|
||||
findOldFashionedImplementedModuleNames().mapNotNull { modelsProvider.findIdeModule(it) }
|
||||
|
||||
@@ -29,6 +29,7 @@ var DataNode<ModuleData>.kotlinAndroidSourceSets: List<KotlinSourceSetInfo>?
|
||||
|
||||
class KotlinSourceSetInfo(val kotlinModule: KotlinModule) {
|
||||
var moduleId: String? = null
|
||||
var gradleModuleId: String = ""
|
||||
var platform: KotlinPlatform = KotlinPlatform.COMMON
|
||||
var defaultCompilerArguments: CommonCompilerArguments? = null
|
||||
var compilerArguments: CommonCompilerArguments? = null
|
||||
|
||||
+2
@@ -619,6 +619,7 @@ open class KotlinMPPGradleProjectResolver : AbstractProjectResolverExtension() {
|
||||
return KotlinSourceSetInfo(sourceSet).also { info ->
|
||||
val languageSettings = sourceSet.languageSettings
|
||||
info.moduleId = getKotlinModuleId(gradleModule, sourceSet, resolverCtx)
|
||||
info.gradleModuleId = getModuleId(resolverCtx, gradleModule)
|
||||
info.platform = sourceSet.platform
|
||||
info.isTestModule = sourceSet.isTestModule
|
||||
info.compilerArguments = createCompilerArguments(emptyList(), sourceSet.platform).also {
|
||||
@@ -642,6 +643,7 @@ open class KotlinMPPGradleProjectResolver : AbstractProjectResolverExtension() {
|
||||
): KotlinSourceSetInfo {
|
||||
return KotlinSourceSetInfo(compilation).also { sourceSetInfo ->
|
||||
sourceSetInfo.moduleId = getKotlinModuleId(gradleModule, compilation, resolverCtx)
|
||||
sourceSetInfo.gradleModuleId = getModuleId(resolverCtx, gradleModule)
|
||||
sourceSetInfo.platform = compilation.platform
|
||||
sourceSetInfo.isTestModule = compilation.isTestModule
|
||||
sourceSetInfo.compilerArguments = createCompilerArguments(compilation.arguments.currentArguments, compilation.platform).also {
|
||||
|
||||
+2
@@ -119,6 +119,8 @@ class KotlinSourceSetDataService : AbstractProjectDataService<GradleSourceSetDat
|
||||
|
||||
isTestModule = kotlinSourceSet.isTestModule
|
||||
|
||||
externalProjectId = kotlinSourceSet.gradleModuleId
|
||||
|
||||
sourceSetNames = kotlinSourceSet.sourceSetIdsByName.values.mapNotNull { sourceSetId ->
|
||||
val node = mainModuleNode.findChildModuleById(sourceSetId) ?: return@mapNotNull null
|
||||
val data = node.data as? ModuleData ?: return@mapNotNull null
|
||||
|
||||
@@ -216,6 +216,8 @@ class KotlinFacetSettings {
|
||||
var kind: KotlinModuleKind = KotlinModuleKind.DEFAULT
|
||||
var sourceSetNames: List<String> = emptyList()
|
||||
var isTestModule: Boolean = false
|
||||
|
||||
var externalProjectId: String = ""
|
||||
}
|
||||
|
||||
interface KotlinFacetSettingsProvider {
|
||||
|
||||
@@ -132,6 +132,7 @@ private fun readV2AndLaterConfig(element: Element): KotlinFacetSettings {
|
||||
} else null
|
||||
} ?: KotlinModuleKind.DEFAULT
|
||||
isTestModule = element.getAttributeValue("isTestModule")?.toBoolean() ?: false
|
||||
externalProjectId = element.getAttributeValue("externalProjectId") ?: ""
|
||||
element.getChild("compilerSettings")?.let {
|
||||
compilerSettings = CompilerSettings()
|
||||
XmlSerializer.deserializeInto(compilerSettings!!, it)
|
||||
@@ -292,6 +293,9 @@ private fun KotlinFacetSettings.writeLatestConfig(element: Element) {
|
||||
element.addContent(Element("newMppModelJpsModuleKind").apply { addContent(kind.name) })
|
||||
element.setAttribute("isTestModule", isTestModule.toString())
|
||||
}
|
||||
if (externalProjectId.isNotEmpty()) {
|
||||
element.setAttribute("externalProjectId", externalProjectId)
|
||||
}
|
||||
productionOutputPath?.let {
|
||||
if (it != (compilerArguments as? K2JSCompilerArguments)?.outputFile) {
|
||||
element.addContent(Element("productionOutputPath").apply { addContent(PathUtil.toSystemIndependentName(it)) })
|
||||
|
||||
Reference in New Issue
Block a user