Refactor MPP versioning

- Use 'null' as indicator of non-MPP version. Consequently, remove
useless 'isMpp' method, and lift all methods to extensions (to be able
to call them on nullable 'facetSettings.mppVersion')

- Change semantics of extensions to check for exact equality rather than
for "at least specified version"

- Deprecate old MPP-versioning in favour of 'facetSettings.mppVersion'

Original commit: 958a7d9315
This commit is contained in:
Dmitry Savvinov
2019-09-05 16:00:55 +03:00
parent 022f9106b1
commit bd153b0606
2 changed files with 12 additions and 11 deletions
@@ -134,6 +134,7 @@ enum class KotlinModuleKind {
SOURCE_SET_HOLDER,
COMPILATION_AND_SOURCE_SET_HOLDER;
@Deprecated("Use KotlinFacetSettings.mppVersion.isNewMpp")
val isNewMPP: Boolean
get() = this != DEFAULT
}
@@ -141,18 +142,18 @@ enum class KotlinModuleKind {
enum class KotlinMultiplatformVersion(val version: Int) {
M1(1), // the first implementation of MPP. Aka 1.2.0 MPP
M2(2), // the "New" MPP. Aka 1.3.0 MPP
M3(3); // the "Hierarchical" MPP.
val isMPPModule: Boolean
get() = version >= 1
val isNewMPP: Boolean
get() = version >= 2
val isHMPP: Boolean
get() = version >= 3
M3(3) // the "Hierarchical" MPP.
}
val KotlinMultiplatformVersion?.isOldMpp: Boolean
get() = this == KotlinMultiplatformVersion.M1
val KotlinMultiplatformVersion?.isNewMPP: Boolean
get() = this == KotlinMultiplatformVersion.M2
val KotlinMultiplatformVersion?.isHmpp: Boolean
get() = this == KotlinMultiplatformVersion.M3
data class ExternalSystemTestTask(val testName: String, val externalSystemProjectId: String, val targetName: String?) {
fun toStringRepresentation() = "$testName|$externalSystemProjectId|$targetName"
@@ -331,7 +331,7 @@ private fun KotlinFacetSettings.writeLatestConfig(element: Element) {
element.setAttribute("externalProjectId", externalProjectId)
}
if (isHmppEnabled) {
element.setAttribute("isHmppProject", isHmppEnabled.toString())
element.setAttribute("isHmppProject", mppVersion.isHmpp.toString())
}
if (externalSystemTestTasks.isNotEmpty()) {
saveElementsList(