Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle Plugin: Simplify coroutines version check #4283

Merged
merged 3 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion gradle-plugins/compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ dependencies {

testImplementation(gradleTestKit())
testImplementation(kotlin("gradle-plugin-api"))
testImplementation(libs.semver4j)

embedded(libs.download.task)
embedded(libs.kotlin.poet)
embedded(libs.semver4j)
embedded(project(":preview-rpc"))
embedded(project(":jdk-version-probe"))
}

val packagesToRelocate = listOf("de.undercouch", "com.squareup.kotlinpoet")
val packagesToRelocate = listOf("de.undercouch", "com.squareup.kotlinpoet", "com.vdurmont.semver4j")

val shadow = tasks.named<ShadowJar>("shadowJar") {
for (packageToRelocate in packagesToRelocate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package org.jetbrains.compose

import com.vdurmont.semver4j.Semver
import groovy.lang.Closure
import org.gradle.api.Plugin
import org.gradle.api.Project
Expand Down Expand Up @@ -97,7 +98,7 @@ abstract class ComposePlugin : Plugin<Project> {
it.resolutionStrategy.eachDependency {
if (it.requested.group.startsWith("org.jetbrains.kotlinx") &&
it.requested.name.startsWith("kotlinx-coroutines-")) {
if (it.requested.version?.startsWith("1.8") != true) {
if (it.requested.version != null && Semver(it.requested.version).isLowerThan("1.8.0-RC2")) {
it.useVersion("1.8.0-RC2")
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.jetbrains.compose.test.tests.integration

import com.vdurmont.semver4j.Semver
import org.gradle.internal.impldep.junit.framework.TestCase.assertTrue
import org.jetbrains.compose.test.utils.GradlePluginTestBase
import org.junit.jupiter.api.Test

class Semver4jTest : GradlePluginTestBase() {

@Test
// we use an external library to compare version numbers, so we have this test to be sure that it works as expected
fun testSemver4j() {
assertTrue(Semver("1.8.0").isGreaterThan(Semver("1.8.0-RC2")))
assertTrue(Semver("1.8.0-RC2").isLowerThan(Semver("1.8.0")))
assertTrue(Semver("1.7.3").isLowerThan(Semver("1.8.0-RC2")))
assertTrue(Semver("1.8.0-RC2").isLowerThan(Semver("1.8.0-RC3")))
}
}
2 changes: 2 additions & 0 deletions gradle-plugins/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ kotlin-poet = "1.16.0"
plugin-android = "7.3.0"
shadow-jar = "8.1.1"
publish-plugin = "1.2.1"
semver4j = "3.1.0"
igordmn marked this conversation as resolved.
Show resolved Hide resolved

[libraries]
download-task = { module = "de.undercouch:gradle-download-task", version.ref = "gradle-download-plugin" }
kotlin-poet = { module = "com.squareup:kotlinpoet", version.ref = "kotlin-poet" }
plugin-android = { module = "com.android.tools.build:gradle", version.ref = "plugin-android" }
plugin-android-api = { module = "com.android.tools.build:gradle-api", version.ref = "plugin-android" }
semver4j = { module = "com.vdurmont:semver4j", version.ref = "semver4j" }

[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
Expand Down
Loading