Add all supported Gradle versions.

^KT-45745 In Progress
This commit is contained in:
Yahor Berdnikau
2021-10-22 16:29:27 +02:00
committed by Space
parent 37b95972db
commit ca3e1b18dc
9 changed files with 46 additions and 31 deletions
@@ -60,6 +60,8 @@ For each test method add `@GradleTest` annotation and `gradleVersion: GradleVers
All tests annotated with `@GradleTest` are [parameterized tests](https://junit.org/junit5/docs/current/user-guide/#writing-tests-parameterized-tests), All tests annotated with `@GradleTest` are [parameterized tests](https://junit.org/junit5/docs/current/user-guide/#writing-tests-parameterized-tests),
where provided parameter is Gradle version. By default, test will receive minimal and latest supported Gradle versions. It is possible where provided parameter is Gradle version. By default, test will receive minimal and latest supported Gradle versions. It is possible
to modify/add additional Gradle versions by adding `@GradleTestVersions` annotation either to the whole suite or to the specific test method. to modify/add additional Gradle versions by adding `@GradleTestVersions` annotation either to the whole suite or to the specific test method.
Prefer using [TestVersions](src/test/kotlin/org/jetbrains/kotlin/gradle/testbase/TestVersions.kt) to define required versions instead of
writing them directly as String.
Use test DSL defined [here](src/test/kotlin/org/jetbrains/kotlin/gradle/testbase/testDsl.kt) to write actual test case: Use test DSL defined [here](src/test/kotlin/org/jetbrains/kotlin/gradle/testbase/testDsl.kt) to write actual test case:
```kotlin ```kotlin
@@ -119,7 +119,7 @@ class BuildCacheRelocationIT : KGPBaseTest() {
} }
@DisplayName("works with Android project") @DisplayName("works with Android project")
@GradleTestVersions(minVersion = "6.7.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_7)
@GradleTest @GradleTest
fun testRelocationAndroidProject(gradleVersion: GradleVersion) { fun testRelocationAndroidProject(gradleVersion: GradleVersion) {
val (firstProject, secondProject) = prepareTestProjects( val (firstProject, secondProject) = prepareTestProjects(
@@ -143,7 +143,7 @@ class BuildCacheRelocationIT : KGPBaseTest() {
} }
@DisplayName("Test relocation for Android with dagger project") @DisplayName("Test relocation for Android with dagger project")
@GradleTestVersions(minVersion = "6.7.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_7)
@GradleTest @GradleTest
fun testRelocationAndroidDagger(gradleVersion: GradleVersion) { fun testRelocationAndroidDagger(gradleVersion: GradleVersion) {
val (firstProject, secondProject) = prepareTestProjects( val (firstProject, secondProject) = prepareTestProjects(
@@ -36,7 +36,7 @@ class ConfigurationAvoidanceIT : KGPBaseTest() {
} }
@DisplayName("Android tasks are not configured") @DisplayName("Android tasks are not configured")
@GradleTestVersions(minVersion = "6.7.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_7)
@GradleTest @GradleTest
fun testAndroidUnrelatedTaskNotConfigured(gradleVersion: GradleVersion) { fun testAndroidUnrelatedTaskNotConfigured(gradleVersion: GradleVersion) {
project( project(
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.gradle.testbase.TestVersions.AGP.AGP_42
import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.DisplayName
@DisplayName("Configuration cache in Android project") @DisplayName("Configuration cache in Android project")
@KGPBaseTest.GradleTestVersions(minVersion = "6.7.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_7)
class ConfigurationCacheForAndroidIT : AbstractConfigurationCacheIT() { class ConfigurationCacheForAndroidIT : AbstractConfigurationCacheIT() {
override val defaultBuildOptions = super.defaultBuildOptions.copy( override val defaultBuildOptions = super.defaultBuildOptions.copy(
androidVersion = AGP_42 androidVersion = AGP_42
@@ -98,7 +98,7 @@ class ConfigurationCacheIT : AbstractConfigurationCacheIT() {
// Set min Gradle version to 6.8 because of using DependencyResolutionManagement API to add repositories. // Set min Gradle version to 6.8 because of using DependencyResolutionManagement API to add repositories.
@DisplayName("with instance execution") @DisplayName("with instance execution")
@GradleTestVersions(minVersion = "6.8.3") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_8)
@GradleTest @GradleTest
fun testInstantExecution(gradleVersion: GradleVersion) { fun testInstantExecution(gradleVersion: GradleVersion) {
project("instantExecution", gradleVersion) { project("instantExecution", gradleVersion) {
@@ -121,7 +121,7 @@ class ConfigurationCacheIT : AbstractConfigurationCacheIT() {
} }
@DisplayName("instant execution works with included build plugin") @DisplayName("instant execution works with included build plugin")
@GradleTestVersions(minVersion = "6.8.3") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_8)
@GradleTest @GradleTest
fun testInstantExecutionWithIncludedBuildPlugin(gradleVersion: GradleVersion) { fun testInstantExecutionWithIncludedBuildPlugin(gradleVersion: GradleVersion) {
project("instantExecutionWithIncludedBuildPlugin", gradleVersion) { project("instantExecutionWithIncludedBuildPlugin", gradleVersion) {
@@ -196,7 +196,7 @@ class ConfigurationCacheIT : AbstractConfigurationCacheIT() {
} }
@DisplayName("works in MPP withJava project") @DisplayName("works in MPP withJava project")
@GradleTestVersions(minVersion = "7.0.2", maxVersion = "7.1.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_7_0, maxVersion = TestVersions.Gradle.G_7_1)
@GradleTest @GradleTest
fun testJvmWithJavaConfigurationCache(gradleVersion: GradleVersion) { fun testJvmWithJavaConfigurationCache(gradleVersion: GradleVersion) {
project("mppJvmWithJava", gradleVersion) { project("mppJvmWithJava", gradleVersion) {
@@ -223,7 +223,7 @@ class ConfigurationCacheIT : AbstractConfigurationCacheIT() {
} }
@SimpleGradlePluginTests @SimpleGradlePluginTests
@KGPBaseTest.GradleTestVersions(minVersion = "6.6.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_6)
abstract class AbstractConfigurationCacheIT : KGPBaseTest() { abstract class AbstractConfigurationCacheIT : KGPBaseTest() {
override val defaultBuildOptions = override val defaultBuildOptions =
super.defaultBuildOptions.copy(configurationCache = true) super.defaultBuildOptions.copy(configurationCache = true)
@@ -22,7 +22,7 @@ import kotlin.io.path.writeText
class JvmTargetValidationTest : KGPBaseTest() { class JvmTargetValidationTest : KGPBaseTest() {
@DisplayName("Should produce warning if java and kotlin jvm targets are different") @DisplayName("Should produce warning if java and kotlin jvm targets are different")
@GradleTestVersions(minVersion = "6.7.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_7)
@GradleTest @GradleTest
internal fun shouldWarnIfJavaAndKotlinJvmTargetsAreDifferent(gradleVersion: GradleVersion) { internal fun shouldWarnIfJavaAndKotlinJvmTargetsAreDifferent(gradleVersion: GradleVersion) {
project( project(
@@ -43,7 +43,7 @@ class JvmTargetValidationTest : KGPBaseTest() {
} }
@DisplayName("Should fail the build if verification mode is 'error' and kotlin and java targets are different") @DisplayName("Should fail the build if verification mode is 'error' and kotlin and java targets are different")
@GradleTestVersions(minVersion = "6.7.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_7)
@GradleTest @GradleTest
internal fun shouldFailBuildIfJavaAndKotlinJvmTargetsAreDifferent(gradleVersion: GradleVersion) { internal fun shouldFailBuildIfJavaAndKotlinJvmTargetsAreDifferent(gradleVersion: GradleVersion) {
project( project(
@@ -70,7 +70,7 @@ class JvmTargetValidationTest : KGPBaseTest() {
} }
@DisplayName("Should ignore if verification mode is 'ignore' and kotlin and java targets are different") @DisplayName("Should ignore if verification mode is 'ignore' and kotlin and java targets are different")
@GradleTestVersions(minVersion = "6.7.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_7)
@GradleTest @GradleTest
internal fun shouldNotPrintAnythingIfJavaAndKotlinJvmTargetsAreDifferent( internal fun shouldNotPrintAnythingIfJavaAndKotlinJvmTargetsAreDifferent(
gradleVersion: GradleVersion gradleVersion: GradleVersion
@@ -99,7 +99,7 @@ class JvmTargetValidationTest : KGPBaseTest() {
} }
@DisplayName("Should not produce warning when java and kotlin jvm targets are the same") @DisplayName("Should not produce warning when java and kotlin jvm targets are the same")
@GradleTestVersions(minVersion = "6.7.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_7)
@GradleTest @GradleTest
internal fun shouldNotWarnOnJavaAndKotlinSameJvmTargets(gradleVersion: GradleVersion) { internal fun shouldNotWarnOnJavaAndKotlinSameJvmTargets(gradleVersion: GradleVersion) {
project( project(
@@ -118,7 +118,7 @@ class JvmTargetValidationTest : KGPBaseTest() {
} }
@DisplayName("Should produce Java-Kotlin jvm target incompatibility warning only for related tasks") @DisplayName("Should produce Java-Kotlin jvm target incompatibility warning only for related tasks")
@GradleTestVersions(minVersion = "6.7.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_7)
@GradleTest @GradleTest
internal fun shouldProduceJavaKotlinJvmTargetDifferenceWarningOnlyForRelatedTasks( internal fun shouldProduceJavaKotlinJvmTargetDifferenceWarningOnlyForRelatedTasks(
gradleVersion: GradleVersion gradleVersion: GradleVersion
@@ -160,7 +160,7 @@ class JvmTargetValidationTest : KGPBaseTest() {
} }
@DisplayName("Should correctly validate JVM targets in mixed Kotlin/Java projects that are using <JDK1.8") @DisplayName("Should correctly validate JVM targets in mixed Kotlin/Java projects that are using <JDK1.8")
@GradleTestVersions(minVersion = "6.7.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_7)
@GradleTest @GradleTest
internal fun oldJdkMixedJavaKotlinTargetVerification(gradleVersion: GradleVersion) { internal fun oldJdkMixedJavaKotlinTargetVerification(gradleVersion: GradleVersion) {
project( project(
@@ -192,7 +192,7 @@ class JvmTargetValidationTest : KGPBaseTest() {
} }
@DisplayName("Should fail the build if verification mode is 'error' and kotlin and java targets are different with no kotlin sources") @DisplayName("Should fail the build if verification mode is 'error' and kotlin and java targets are different with no kotlin sources")
@GradleTestVersions(minVersion = "6.7.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_7)
@GradleTest @GradleTest
internal fun shouldFailBuildIfJavaAndKotlinJvmTargetsAreDifferentWithNoKotlinSources(gradleVersion: GradleVersion) { internal fun shouldFailBuildIfJavaAndKotlinJvmTargetsAreDifferentWithNoKotlinSources(gradleVersion: GradleVersion) {
project( project(
@@ -240,7 +240,7 @@ class JvmTargetValidationTest : KGPBaseTest() {
} }
@DisplayName("Should do JVM target validation if java sources are added and configuration cache is reused") @DisplayName("Should do JVM target validation if java sources are added and configuration cache is reused")
@GradleTestVersions(minVersion = "6.6.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_6)
@GradleTest @GradleTest
@ExperimentalPathApi @ExperimentalPathApi
internal fun shouldDoJvmTargetValidationOnNewJavaSourcesAndConfigurationCacheReuse(gradleVersion: GradleVersion) { internal fun shouldDoJvmTargetValidationOnNewJavaSourcesAndConfigurationCacheReuse(gradleVersion: GradleVersion) {
@@ -19,7 +19,7 @@ import java.io.File
@DisplayName("Kotlin Java Toolchain support") @DisplayName("Kotlin Java Toolchain support")
class KotlinJavaToolchainTest : KGPBaseTest() { class KotlinJavaToolchainTest : KGPBaseTest() {
@GradleTestVersions(additionalVersions = ["6.7.1"]) @GradleTestVersions(additionalVersions = [TestVersions.Gradle.G_6_7])
@GradleTest @GradleTest
@DisplayName("Should use by default same jvm as Gradle daemon for jdkHome") @DisplayName("Should use by default same jvm as Gradle daemon for jdkHome")
internal fun byDefaultShouldUseGradleJDK(gradleVersion: GradleVersion) { internal fun byDefaultShouldUseGradleJDK(gradleVersion: GradleVersion) {
@@ -102,7 +102,7 @@ class KotlinJavaToolchainTest : KGPBaseTest() {
} }
@DisplayName("Kotlin compile task should reuse build cache when toolchain is set and build is happening on different JDKs") @DisplayName("Kotlin compile task should reuse build cache when toolchain is set and build is happening on different JDKs")
@GradleTestVersions(minVersion = "6.7.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_7)
@GradleTest @GradleTest
internal fun differentBuildJDKBuildCacheHit(gradleVersion: GradleVersion) { internal fun differentBuildJDKBuildCacheHit(gradleVersion: GradleVersion) {
val buildCache = workingDir.resolve("custom-jdk-build-cache") val buildCache = workingDir.resolve("custom-jdk-build-cache")
@@ -331,7 +331,7 @@ class KotlinJavaToolchainTest : KGPBaseTest() {
} }
@DisplayName("Should allow to set JDK version for tasks via Java toolchain") @DisplayName("Should allow to set JDK version for tasks via Java toolchain")
@GradleTestVersions(minVersion = "6.7.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_7)
@GradleTest @GradleTest
internal fun setJdkUsingJavaToolchain(gradleVersion: GradleVersion) { internal fun setJdkUsingJavaToolchain(gradleVersion: GradleVersion) {
project( project(
@@ -346,7 +346,7 @@ class KotlinJavaToolchainTest : KGPBaseTest() {
} }
@DisplayName("Should allow to set Java toolchain via extension") @DisplayName("Should allow to set Java toolchain via extension")
@GradleTestVersions(minVersion = "6.7.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_7)
@GradleTest @GradleTest
internal fun setJdkUsingJavaToolchainViaExtension(gradleVersion: GradleVersion) { internal fun setJdkUsingJavaToolchainViaExtension(gradleVersion: GradleVersion) {
project( project(
@@ -361,7 +361,7 @@ class KotlinJavaToolchainTest : KGPBaseTest() {
} }
@DisplayName("Toolchain should be correctly supported in multiplatform plugin jvm targets") @DisplayName("Toolchain should be correctly supported in multiplatform plugin jvm targets")
@GradleTestVersions(minVersion = "6.7.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_7)
@GradleTest @GradleTest
internal fun toolchainCorrectlySupportedInMPPlugin(gradleVersion: GradleVersion) { internal fun toolchainCorrectlySupportedInMPPlugin(gradleVersion: GradleVersion) {
project( project(
@@ -419,7 +419,7 @@ class KotlinJavaToolchainTest : KGPBaseTest() {
} }
@DisplayName("Should set 'jvmTarget' option if user does not specify it explicitly via toolchain setter") @DisplayName("Should set 'jvmTarget' option if user does not specify it explicitly via toolchain setter")
@GradleTestVersions(minVersion = "6.7.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_7)
@GradleTest @GradleTest
internal fun shouldSetJvmTargetNonSpecifiedByUserViaToolchain(gradleVersion: GradleVersion) { internal fun shouldSetJvmTargetNonSpecifiedByUserViaToolchain(gradleVersion: GradleVersion) {
project( project(
@@ -456,7 +456,7 @@ class KotlinJavaToolchainTest : KGPBaseTest() {
} }
@DisplayName("Setting toolchain via java extension should also affect Kotlin compilations") @DisplayName("Setting toolchain via java extension should also affect Kotlin compilations")
@GradleTestVersions(minVersion = "6.7.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_7)
@GradleTest @GradleTest
internal fun settingToolchainViaJavaShouldAlsoWork(gradleVersion: GradleVersion) { internal fun settingToolchainViaJavaShouldAlsoWork(gradleVersion: GradleVersion) {
project( project(
@@ -488,7 +488,7 @@ class KotlinJavaToolchainTest : KGPBaseTest() {
} }
@DisplayName("Build should not produce warninings when '-no-jdk' option is present") @DisplayName("Build should not produce warninings when '-no-jdk' option is present")
@GradleTestVersions(minVersion = "6.7.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_7)
@GradleTest @GradleTest
internal fun noWarningOnNoJdkOptionPresent(gradleVersion: GradleVersion) { internal fun noWarningOnNoJdkOptionPresent(gradleVersion: GradleVersion) {
project( project(
@@ -520,7 +520,7 @@ class KotlinJavaToolchainTest : KGPBaseTest() {
} }
@DisplayName("Toolchain should take into account kotlin options that are set via android extension") @DisplayName("Toolchain should take into account kotlin options that are set via android extension")
@GradleTestVersions(minVersion = "6.7.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_7)
@GradleTest @GradleTest
internal fun kotlinOptionsAndroidAndToolchain(gradleVersion: GradleVersion) { internal fun kotlinOptionsAndroidAndToolchain(gradleVersion: GradleVersion) {
project("android".fullProjectName, gradleVersion) { project("android".fullProjectName, gradleVersion) {
@@ -544,7 +544,7 @@ class KotlinJavaToolchainTest : KGPBaseTest() {
} }
@DisplayName("Toolchain should not make an exception when build is running on JDK 11, but toolchain is set to JDK 1.8") @DisplayName("Toolchain should not make an exception when build is running on JDK 11, but toolchain is set to JDK 1.8")
@GradleTestVersions(minVersion = "6.7.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_7)
@GradleTest @GradleTest
internal fun shouldNotRaiseErrorOnJDK11withJDK1_8Toolchain(gradleVersion: GradleVersion) { internal fun shouldNotRaiseErrorOnJDK11withJDK1_8Toolchain(gradleVersion: GradleVersion) {
project( project(
@@ -559,7 +559,7 @@ class KotlinJavaToolchainTest : KGPBaseTest() {
} }
@DisplayName("JVM target shouldn't be changed when toolchain is not configured") @DisplayName("JVM target shouldn't be changed when toolchain is not configured")
@GradleTestVersions(minVersion = "6.7.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_7)
@GradleTest @GradleTest
internal fun shouldNotChangeJvmTargetWithNoToolchain(gradleVersion: GradleVersion) { internal fun shouldNotChangeJvmTargetWithNoToolchain(gradleVersion: GradleVersion) {
project( project(
@@ -586,7 +586,7 @@ class KotlinJavaToolchainTest : KGPBaseTest() {
} }
@DisplayName("Kotlin toolchain should support configuration cache") @DisplayName("Kotlin toolchain should support configuration cache")
@GradleTestVersions(minVersion = "6.7.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_6_7)
@GradleTest @GradleTest
internal fun testConfigurationCache(gradleVersion: GradleVersion) { internal fun testConfigurationCache(gradleVersion: GradleVersion) {
project( project(
@@ -151,7 +151,7 @@ class SimpleKotlinGradleIT : KGPBaseTest() {
// https://sourceforge.net/p/proguard/bugs/735/ // https://sourceforge.net/p/proguard/bugs/735/
// Gradle 7 compatibility issue: https://github.com/Guardsquare/proguard/issues/136 // Gradle 7 compatibility issue: https://github.com/Guardsquare/proguard/issues/136
@GradleTest @GradleTest
@GradleTestVersions(maxVersion = "6.8.3") @GradleTestVersions(maxVersion = TestVersions.Gradle.G_6_8)
@DisplayName("Should correctly interop with ProGuard") @DisplayName("Should correctly interop with ProGuard")
fun testInteropWithProguarded(gradleVersion: GradleVersion) { fun testInteropWithProguarded(gradleVersion: GradleVersion) {
project( project(
@@ -223,7 +223,7 @@ class SimpleKotlinGradleIT : KGPBaseTest() {
@GradleTest @GradleTest
@DisplayName("Should be compatible with project isolation") @DisplayName("Should be compatible with project isolation")
@GradleTestVersions(minVersion = "7.1.1", maxVersion = "7.1.1") @GradleTestVersions(minVersion = TestVersions.Gradle.G_7_1, maxVersion = TestVersions.Gradle.G_7_1)
fun testProjectIsolation(gradleVersion: GradleVersion) { fun testProjectIsolation(gradleVersion: GradleVersion) {
project( project(
projectName = "instantExecution", projectName = "instantExecution",
@@ -9,8 +9,21 @@ import org.jetbrains.kotlin.gradle.utils.minSupportedGradleVersion
interface TestVersions { interface TestVersions {
object Gradle { object Gradle {
const val G_6_1 = "6.1.1"
const val G_6_2 = "6.2.2"
const val G_6_3 = "6.3"
const val G_6_4 = "6.4.1"
const val G_6_5 = "6.5.1"
const val G_6_6 = "6.6.1"
const val G_6_7 = "6.7.1"
const val G_6_8 = "6.8.3"
const val G_6_9 = "6.9.1"
const val G_7_0 = "7.0.2"
const val G_7_1 = "7.1.1"
const val G_7_2 = "7.2"
const val G_7_3 = "7.3-rc-2"
const val MIN_SUPPORTED = minSupportedGradleVersion const val MIN_SUPPORTED = minSupportedGradleVersion
const val MAX_SUPPORTED = "7.0" const val MAX_SUPPORTED = G_7_0
} }
object Kotlin { object Kotlin {