From bae41dd984840614c7ad0ed36d453b8cdc36efc5 Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Tue, 3 Sep 2024 13:26:49 +0200 Subject: [PATCH 1/7] set kmp version --- .../multiplatform/gradle/SourceSetAutoInstallExtension.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sentry-kotlin-multiplatform-gradle-plugin/src/main/java/io/sentry/kotlin/multiplatform/gradle/SourceSetAutoInstallExtension.kt b/sentry-kotlin-multiplatform-gradle-plugin/src/main/java/io/sentry/kotlin/multiplatform/gradle/SourceSetAutoInstallExtension.kt index c2dff1351..71d4c301a 100644 --- a/sentry-kotlin-multiplatform-gradle-plugin/src/main/java/io/sentry/kotlin/multiplatform/gradle/SourceSetAutoInstallExtension.kt +++ b/sentry-kotlin-multiplatform-gradle-plugin/src/main/java/io/sentry/kotlin/multiplatform/gradle/SourceSetAutoInstallExtension.kt @@ -19,10 +19,11 @@ abstract class SourceSetAutoInstallExtension @Inject constructor(project: Projec /** * Overrides the default Sentry Kotlin Multiplatform SDK dependency version. * - * Defaults to the latest version of the Sentry Kotlin Multiplatform SDK. + * Defaults to the latest version of the Sentry Kotlin Multiplatform SDK which is + * the same as the version of the Sentry Gradle Plugin. */ val sentryKmpVersion: Property = objects .property(String::class.java) - .convention("latest.release") // Replace with the actual default version + .convention(project.version.toString()) } From 36d8abe1d25ef773a2ff5ce2ab5ed636231269ce Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Tue, 3 Sep 2024 13:31:00 +0200 Subject: [PATCH 2/7] update --- sentry-kotlin-multiplatform-gradle-plugin/build.gradle.kts | 5 +++++ .../multiplatform/gradle/SourceSetAutoInstallExtension.kt | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/sentry-kotlin-multiplatform-gradle-plugin/build.gradle.kts b/sentry-kotlin-multiplatform-gradle-plugin/build.gradle.kts index f457018c3..af2872581 100644 --- a/sentry-kotlin-multiplatform-gradle-plugin/build.gradle.kts +++ b/sentry-kotlin-multiplatform-gradle-plugin/build.gradle.kts @@ -95,6 +95,11 @@ buildConfig { "SentryCocoaVersion", provider { "\"${project.property("sentryCocoaVersion")}\"" } ) + buildConfigField( + "String", + "SentryKmpVersion", + provider { "\"${project.property("versionName")}\"" } + ) } detekt { config.setFrom(rootProject.files("../config/detekt/detekt.yml")) } diff --git a/sentry-kotlin-multiplatform-gradle-plugin/src/main/java/io/sentry/kotlin/multiplatform/gradle/SourceSetAutoInstallExtension.kt b/sentry-kotlin-multiplatform-gradle-plugin/src/main/java/io/sentry/kotlin/multiplatform/gradle/SourceSetAutoInstallExtension.kt index 71d4c301a..6e4ec17c2 100644 --- a/sentry-kotlin-multiplatform-gradle-plugin/src/main/java/io/sentry/kotlin/multiplatform/gradle/SourceSetAutoInstallExtension.kt +++ b/sentry-kotlin-multiplatform-gradle-plugin/src/main/java/io/sentry/kotlin/multiplatform/gradle/SourceSetAutoInstallExtension.kt @@ -1,5 +1,6 @@ package io.sentry.kotlin.multiplatform.gradle +import io.sentry.BuildConfig import org.gradle.api.Project import org.gradle.api.provider.Property import javax.inject.Inject @@ -19,11 +20,10 @@ abstract class SourceSetAutoInstallExtension @Inject constructor(project: Projec /** * Overrides the default Sentry Kotlin Multiplatform SDK dependency version. * - * Defaults to the latest version of the Sentry Kotlin Multiplatform SDK which is - * the same as the version of the Sentry Gradle Plugin. + * Defaults to the version of this plugin which is synchronized with the KMP SDK version. */ val sentryKmpVersion: Property = objects .property(String::class.java) - .convention(project.version.toString()) + .convention(BuildConfig.SentryKmpVersion) } From 9fce1b4f85576f8bccc9e184c8436cf5fc9abe2b Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Tue, 3 Sep 2024 13:36:45 +0200 Subject: [PATCH 3/7] update test --- .../multiplatform/gradle/SentryPluginTest.kt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sentry-kotlin-multiplatform-gradle-plugin/src/test/java/io/sentry/kotlin/multiplatform/gradle/SentryPluginTest.kt b/sentry-kotlin-multiplatform-gradle-plugin/src/test/java/io/sentry/kotlin/multiplatform/gradle/SentryPluginTest.kt index dfa841aae..a21e23abd 100644 --- a/sentry-kotlin-multiplatform-gradle-plugin/src/test/java/io/sentry/kotlin/multiplatform/gradle/SentryPluginTest.kt +++ b/sentry-kotlin-multiplatform-gradle-plugin/src/test/java/io/sentry/kotlin/multiplatform/gradle/SentryPluginTest.kt @@ -1,14 +1,12 @@ package io.sentry.kotlin.multiplatform.gradle +import io.sentry.BuildConfig import org.gradle.api.plugins.ExtensionAware import org.gradle.testfixtures.ProjectBuilder import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertNotNull -import org.junit.jupiter.api.Assertions.assertNull -import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test import org.junit.jupiter.api.io.TempDir import java.io.File @@ -74,6 +72,15 @@ class SentryPluginTest { assertNotNull(project.extensions.getByName("commonMain")) } + @Test + fun `default kmp version is set in commonMain extension`() { + val project = ProjectBuilder.builder().build() + project.pluginManager.apply("io.sentry.kotlin.multiplatform.gradle") + + val autoInstallExtension = project.extensions.getByName("autoInstall") as AutoInstallExtension + assertEquals(BuildConfig.SentryKmpVersion, autoInstallExtension.commonMain.sentryKmpVersion.get()) + } + @Test fun `when autoInstall is disabled, no installations are performed`() { val project = ProjectBuilder.builder().build() From 1712225dffc639b5e6c562d4c8e3d67264aaa264 Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Tue, 3 Sep 2024 13:52:39 +0200 Subject: [PATCH 4/7] update --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cd56464e..f2ec3645d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Features + +- Plugin: dont use `latest.release` as default for the KMP dependency ([#262](https://github.com/getsentry/sentry-kotlin-multiplatform/pull/262)) + ### Dependencies - **Gradle Plugin:** Bump default Cocoa SDK from v8.26.0 to v8.36.0 ([#261](https://github.com/getsentry/sentry-kotlin-multiplatform/pull/261)) From 5a7c5cfd5fe9b8dfec1f2d2b5ff199e8dbb9ed40 Mon Sep 17 00:00:00 2001 From: Giancarlo Buenaflor Date: Tue, 3 Sep 2024 14:39:27 +0200 Subject: [PATCH 5/7] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2ec3645d..f53cdc26f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -### Features +### Improvements - Plugin: dont use `latest.release` as default for the KMP dependency ([#262](https://github.com/getsentry/sentry-kotlin-multiplatform/pull/262)) From 1a12a380de6396104f978ef336bfece84622001b Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Wed, 4 Sep 2024 14:54:24 +0200 Subject: [PATCH 6/7] updatE --- .../sentry/kotlin/multiplatform/gradle/SentryPluginTest.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sentry-kotlin-multiplatform-gradle-plugin/src/test/java/io/sentry/kotlin/multiplatform/gradle/SentryPluginTest.kt b/sentry-kotlin-multiplatform-gradle-plugin/src/test/java/io/sentry/kotlin/multiplatform/gradle/SentryPluginTest.kt index a21e23abd..d4d8bf800 100644 --- a/sentry-kotlin-multiplatform-gradle-plugin/src/test/java/io/sentry/kotlin/multiplatform/gradle/SentryPluginTest.kt +++ b/sentry-kotlin-multiplatform-gradle-plugin/src/test/java/io/sentry/kotlin/multiplatform/gradle/SentryPluginTest.kt @@ -6,7 +6,10 @@ import org.gradle.testfixtures.ProjectBuilder import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType -import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertNotNull +import org.junit.jupiter.api.Assertions.assertNull +import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test import org.junit.jupiter.api.io.TempDir import java.io.File From 16e93e6949fce17003447eadb0393f7577176bd0 Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Wed, 4 Sep 2024 14:59:45 +0200 Subject: [PATCH 7/7] add more tests --- .../multiplatform/gradle/SentryPluginTest.kt | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/sentry-kotlin-multiplatform-gradle-plugin/src/test/java/io/sentry/kotlin/multiplatform/gradle/SentryPluginTest.kt b/sentry-kotlin-multiplatform-gradle-plugin/src/test/java/io/sentry/kotlin/multiplatform/gradle/SentryPluginTest.kt index d4d8bf800..0cf1a25f8 100644 --- a/sentry-kotlin-multiplatform-gradle-plugin/src/test/java/io/sentry/kotlin/multiplatform/gradle/SentryPluginTest.kt +++ b/sentry-kotlin-multiplatform-gradle-plugin/src/test/java/io/sentry/kotlin/multiplatform/gradle/SentryPluginTest.kt @@ -12,6 +12,8 @@ import org.junit.jupiter.api.Assertions.assertNull import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test import org.junit.jupiter.api.io.TempDir +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.ValueSource import java.io.File class SentryPluginTest { @@ -80,8 +82,31 @@ class SentryPluginTest { val project = ProjectBuilder.builder().build() project.pluginManager.apply("io.sentry.kotlin.multiplatform.gradle") + val sourceSetAutoInstallExtension = project.extensions.getByName("commonMain") as SourceSetAutoInstallExtension + assertEquals(BuildConfig.SentryKmpVersion, sourceSetAutoInstallExtension.sentryKmpVersion.get()) + } + + @Test + fun `custom kmp version overrides default in commonMain extension`() { + val project = ProjectBuilder.builder().build() + project.pluginManager.apply("io.sentry.kotlin.multiplatform.gradle") + + val autoInstallExtension = project.extensions.getByName("autoInstall") as AutoInstallExtension + autoInstallExtension.commonMain.sentryKmpVersion.set("1.2.3") + + assertEquals("1.2.3", autoInstallExtension.commonMain.sentryKmpVersion.get()) + } + + @ParameterizedTest + @ValueSource(strings = ["1.0.0", "2.3.4-SNAPSHOT", "latest.release"]) + fun `sentryKmpVersion accepts various version formats in commonMain extension`(version: String) { + val project = ProjectBuilder.builder().build() + project.pluginManager.apply("io.sentry.kotlin.multiplatform.gradle") + val autoInstallExtension = project.extensions.getByName("autoInstall") as AutoInstallExtension - assertEquals(BuildConfig.SentryKmpVersion, autoInstallExtension.commonMain.sentryKmpVersion.get()) + autoInstallExtension.commonMain.sentryKmpVersion.set(version) + + assertEquals(version, autoInstallExtension.commonMain.sentryKmpVersion.get()) } @Test