From dc4bbbc3339316ccfb8b72a5d413ed6586448c7c Mon Sep 17 00:00:00 2001 From: Dmitry Savvinov Date: Thu, 20 Apr 2023 13:39:08 +0200 Subject: [PATCH] [mpp] Minor: drop warning about deprecated K/N test binary access --- .../kotlin/gradle/native/GeneralNativeIT.kt | 28 +--------------- .../testProject/native-tests/build.gradle | 20 +----------- .../gradle/dsl/KotlinNativeBinaryContainer.kt | 32 +------------------ 3 files changed, 3 insertions(+), 77 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/GeneralNativeIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/GeneralNativeIT.kt index 50f61ac3d88..8e9368f4b82 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/GeneralNativeIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/GeneralNativeIT.kt @@ -804,7 +804,7 @@ class GeneralNativeIT : BaseGradleIT() { @Test fun testNativeTestGetters() = with(transformNativeTestProject("native-tests")) { // Check that test binaries can be accessed in a buildscript. - build("checkNewGetters") { + build("checkGetters") { assertSuccessful() val suffix = if (HostManager.hostIsMingw) "exe" else "kexe" val names = listOf("test", "another") @@ -815,32 +815,6 @@ class GeneralNativeIT : BaseGradleIT() { assertContains("Find test: $it") } } - - // Check that accessing a test as an executable fails or returns null and shows the corresponding warning. - build("checkOldGet") { - assertFailed() - assertContains( - """ - |Probably you are accessing the default test binary using the 'binaries.getExecutable("test", DEBUG)' method. - |Since 1.3.40 tests are represented by a separate binary type. To get the default test binary, use: - | - | binaries.getTest("DEBUG") - """.trimMargin() - ) - } - - build("checkOldFind") { - assertSuccessful() - assertContains( - """ - |Probably you are accessing the default test binary using the 'binaries.findExecutable("test", DEBUG)' method. - |Since 1.3.40 tests are represented by a separate binary type. To get the default test binary, use: - | - | binaries.findTest("DEBUG") - """.trimMargin() - ) - assertContains("Find test: null") - } } @Test diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-tests/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-tests/build.gradle index 17713ec9d21..6cecaa7f0f0 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-tests/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-tests/build.gradle @@ -50,25 +50,7 @@ configure([hostTest, iosTest, iosArm64Test]){ } } -// Check that getting a test binary in an old way fails showing the corresponding warning -task checkOldGet { - doLast { - configure([kotlin.targets.host]) { - println("Get test: ${binaries.getExecutable("test", DEBUG)}") - } - } -} - -// Check that finding a test binary in an old way returns null showing the corresponding warning. -task checkOldFind { - doLast { - configure([kotlin.targets.host]) { - println("Find test: ${binaries.findExecutable("test", DEBUG)}") - } - } -} - -task checkNewGetters { +task checkGetters { doLast { configure([kotlin.targets.host]) { println("Get test: ${binaries.getTest(DEBUG).outputFile.name}") diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinNativeBinaryContainer.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinNativeBinaryContainer.kt index 09f09bdacd6..9741cab0429 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinNativeBinaryContainer.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinNativeBinaryContainer.kt @@ -75,14 +75,7 @@ abstract class KotlinNativeBinaryContainer @Inject constructor( override fun getByName(name: String): NativeBinary = nameToBinary.getValue(name) override fun findByName(name: String): NativeBinary? = nameToBinary[name] - private fun checkDeprecatedTestAccess(namePrefix: String, buildType: NativeBuildType, warning: String) { - if (namePrefix == DEFAULT_TEST_NAME_PREFIX && buildType == DEFAULT_TEST_BUILD_TYPE) { - project.logger.warn(warning) - } - } - override fun getExecutable(namePrefix: String, buildType: NativeBuildType): Executable { - checkDeprecatedTestAccess(namePrefix, buildType, GET_TEST_DEPRECATION_WARNING) return getBinary(namePrefix, buildType, NativeOutputKind.EXECUTABLE) } @@ -99,7 +92,6 @@ abstract class KotlinNativeBinaryContainer @Inject constructor( getBinary(namePrefix, buildType, NativeOutputKind.TEST) override fun findExecutable(namePrefix: String, buildType: NativeBuildType): Executable? { - checkDeprecatedTestAccess(namePrefix, buildType, FIND_TEST_DEPRECATED_WARNING) return findBinary(namePrefix, buildType, NativeOutputKind.EXECUTABLE) } @@ -154,10 +146,7 @@ abstract class KotlinNativeBinaryContainer @Inject constructor( } companion object { - internal val DEFAULT_TEST_BUILD_TYPE = NativeBuildType.DEBUG - internal val DEFAULT_TEST_NAME_PREFIX = "test" - - internal fun generateBinaryName(prefix: String, buildType: NativeBuildType, outputKindClassifier: String) = + internal fun generateBinaryName(prefix: String, buildType: NativeBuildType, outputKindClassifier: String) = lowerCamelCaseName(prefix, buildType.getName(), outputKindClassifier) internal fun extractPrefixFromBinaryName(name: String, buildType: NativeBuildType, outputKindClassifier: String): String { @@ -167,25 +156,6 @@ abstract class KotlinNativeBinaryContainer @Inject constructor( else name.substringBeforeLast(suffix.capitalizeAsciiOnly()) } - - // TODO: Remove in 1.3.50. - private val GET_TEST_DEPRECATION_WARNING = """ - | - |Probably you are accessing the default test binary using the 'binaries.getExecutable("$DEFAULT_TEST_NAME_PREFIX", ${DEFAULT_TEST_BUILD_TYPE.name})' method. - |Since 1.3.40 tests are represented by a separate binary type. To get the default test binary, use: - | - | binaries.getTest("DEBUG") - | - """.trimMargin() - - private val FIND_TEST_DEPRECATED_WARNING = """ - | - |Probably you are accessing the default test binary using the 'binaries.findExecutable("$DEFAULT_TEST_NAME_PREFIX", ${DEFAULT_TEST_BUILD_TYPE.name})' method. - |Since 1.3.40 tests are represented by a separate binary type. To get the default test binary, use: - | - | binaries.findTest("DEBUG") - | - """.trimMargin() } // endregion.