Browse Source

Upgrade semver checks and set dev version with new compiler plugin. (#4705)

pull/4707/head
Konstantin 8 months ago committed by GitHub
parent
commit
0c886be631
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerKotlinSupportPlugin.kt
  2. 27
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/Version.kt
  3. 5
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/KotlinCompatibilityTest.kt
  4. 8
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/unit/SemVerTest.kt
  5. 6
      gradle-plugins/compose/src/test/test-projects/application/mpp/settings.gradle

4
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerKotlinSupportPlugin.kt

@ -35,10 +35,10 @@ internal fun Project.configureComposeCompilerPlugin() {
}
}
internal const val newCompilerIsAvailableVersion = "2.0.0-RC2"
internal const val newCompilerIsAvailableVersion = "2.0.0-RC2-238"
internal const val newComposeCompilerKotlinSupportPluginId = "org.jetbrains.kotlin.plugin.compose"
internal const val newComposeCompilerError =
"Since Kotlin $newCompilerIsAvailableVersion to use Compose Multiplatform " +
"Since Kotlin 2.0.0-RC2 to use Compose Multiplatform " +
"you must apply \"$newComposeCompilerKotlinSupportPluginId\" plugin." +
"\nSee the migration guide https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-compiler/compose-compiler.html#migrating-a-compose-multiplatform-project"

27
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/Version.kt

@ -1,11 +1,13 @@
package org.jetbrains.compose.internal
import kotlin.math.min
internal data class Version(
val major: Int,
val minor: Int,
val patch: Int,
val meta: String
): Comparable<Version> {
) : Comparable<Version> {
override fun compareTo(other: Version): Int = when {
major != other.major -> major - other.major
minor != other.minor -> minor - other.minor
@ -13,14 +15,33 @@ internal data class Version(
else -> {
if (meta.isEmpty()) 1
else if (other.meta.isEmpty()) -1
else meta.compareTo(other.meta)
else {
val metaParts = meta.split("-")
val otherMetaParts = other.meta.split("-")
var result = 0
for (i in 0 until min(metaParts.size, otherMetaParts.size)) {
val metaPart = metaParts[i]
val otherMetaPart = otherMetaParts[i]
if (metaPart != otherMetaPart) {
result = metaPart.compareTo(otherMetaPart)
break
}
}
if (result != 0) result
else {
if (metaParts.size < otherMetaParts.size) 1
else if (metaParts.size > otherMetaParts.size) -1
else 0
}
}
}
}
companion object {
private val SEMVER_REGEXP = """^(\d+)(?:\.(\d*))?(?:\.(\d*))?(?:-(.*))?${'$'}""".toRegex()
fun fromString(versionString: String): Version {
val matchResult: MatchResult = SEMVER_REGEXP.matchEntire(versionString) ?: return Version(0,0,0, "")
val matchResult: MatchResult = SEMVER_REGEXP.matchEntire(versionString) ?: return Version(0, 0, 0, "")
val major: Int = matchResult.groups[1]?.value?.toInt() ?: 0
val minor: Int = matchResult.groups[2]?.value?.toInt() ?: 0
val patch: Int = matchResult.groups[3]?.value?.toInt() ?: 0

5
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/KotlinCompatibilityTest.kt

@ -49,9 +49,10 @@ class KotlinCompatibilityTest : GradlePluginTestBase() {
}
}
/* TODO uncomment the test when Kotlin RC2 will be published
@Test
fun testNewCompilerPluginError() {
// TODO replace by this after Kotlin 2.0 release
// testEnvironment = defaultTestEnvironment.copy(kotlinVersion = "2.0")
val testProject = testProject(
TestProjects.mpp,
testEnvironment = defaultTestEnvironment.copy(kotlinVersion = newCompilerIsAvailableVersion)
@ -59,5 +60,5 @@ class KotlinCompatibilityTest : GradlePluginTestBase() {
testProject.gradleFailure("tasks").checks {
check.logContains(newComposeCompilerError)
}
}*/
}
}

8
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/unit/SemVerTest.kt

@ -15,5 +15,13 @@ class SemVerTest {
assert(Version.fromString("2.0.0-RC1") > Version.fromString("1.9.23"))
assert(Version.fromString("2.0.0") > Version.fromString("2.0.0-RC1"))
assert(Version.fromString("2.0.0-RC1") == Version.fromString("2.0.0-RC1"))
assert(Version.fromString("2.0.0-RC2") > Version.fromString("2.0.0-RC2-238"))
assert(Version.fromString("2.0.0-RC2-239") > Version.fromString("2.0.0-RC2-238"))
assert(Version.fromString("2.0.0-RC3-111") > Version.fromString("2.0.0-RC2-999"))
assert(Version.fromString("2.0.0-RC3-111") > Version.fromString("2.0.0-RC3-111-9"))
assert(Version.fromString("2.0.0-RC3-112-9") > Version.fromString("2.0.0-RC3-111-9"))
assert(Version.fromString("2.0.0") > Version.fromString("2.0.0-RC3-111-9"))
assert(Version.fromString("2.0.0-RC1") > Version.fromString("2.0.0--"))
assert(Version.fromString("2.0.0-RC3-112-9") == Version.fromString("2.0.0-RC3-112-9"))
}
}

6
gradle-plugins/compose/src/test/test-projects/application/mpp/settings.gradle

@ -12,6 +12,9 @@ pluginManagement {
maven {
url 'https://maven.pkg.jetbrains.space/public/p/compose/dev'
}
maven {
url 'https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/'
}
}
}
dependencyResolutionManagement {
@ -22,6 +25,9 @@ dependencyResolutionManagement {
maven {
url 'https://maven.pkg.jetbrains.space/public/p/compose/dev'
}
maven {
url 'https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/'
}
}
}
rootProject.name = "mpp"
Loading…
Cancel
Save