From 7638b95a315bf4c7ce47a440e54884514178a9f5 Mon Sep 17 00:00:00 2001 From: "Alexander.Likhachev" Date: Mon, 23 Jan 2023 17:47:58 +0100 Subject: [PATCH] [Gradle] Add integration tests for KT-56131 --- .../gradle/mpp/BrokenLazyConfigurationIT.kt | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/mpp/BrokenLazyConfigurationIT.kt diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/mpp/BrokenLazyConfigurationIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/mpp/BrokenLazyConfigurationIT.kt new file mode 100644 index 00000000000..028be415e47 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/mpp/BrokenLazyConfigurationIT.kt @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.gradle.mpp + +import org.gradle.util.GradleVersion +import org.jetbrains.kotlin.gradle.testbase.* +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.DisplayName + +@MppGradlePluginTests +@DisplayName("Broken task configuration avoidance doesn't lead to build failures at least with simple setups") +class BrokenLazyConfigurationIT : KGPBaseTest() { + @GradleTest + @DisplayName("works in JVM") + fun testBrokenTcaInJvm(gradleVersion: GradleVersion) { + project("kotlinJavaProject", gradleVersion) { + buildGradle.modify { + it.replace( + "sourceSets {", + """ + tasks.whenTaskAdded {} // break lazy initialization of all tasks + sourceSets { + """.trimIndent() + ) + } + build("build") + } + } + + @GradleTest + @DisplayName("works in JS") + fun testBrokenTcaInJs(gradleVersion: GradleVersion) { + project("kotlin-js-browser-project", gradleVersion) { + val subprojects = listOf("app", "base", "lib") + for (subproject in subprojects) { + subProject(subproject).buildGradleKts.modify { + it.replace( + "dependencies {", + """ + tasks.whenTaskAdded {} // break lazy initialization of all tasks + dependencies { + """.trimIndent() + ) + } + } + build("build") + } + } + + @GradleTest + @DisplayName("works in MPP") // aka KT-56131 + @Disabled + fun testBrokenTcaInMpp(gradleVersion: GradleVersion) { + project("new-mpp-lib-with-tests", gradleVersion) { + buildGradle.modify { + it.replace( + "apply plugin: 'kotlin-multiplatform'", + """ + tasks.whenTaskAdded {} // break lazy initialization of all tasks + apply plugin: 'kotlin-multiplatform' + """.trimIndent() + ) + } + build("build") + } + } +} \ No newline at end of file