From 1660fc7e892d2d319e2654590d41243ff1fca6e6 Mon Sep 17 00:00:00 2001 From: Tad Fisher Date: Thu, 23 Feb 2023 16:53:56 -0800 Subject: [PATCH] Test with Gradle 8.0.1 and Kotlin 1.8.10 --- .../gradle/ktlint/KotlinJsPluginTests.kt | 2 +- .../gradle/ktlint/KtlintIdeaPluginTest.kt | 4 ++-- .../gradle/ktlint/testdsl/testAnnotations.kt | 17 ++++++++++++----- .../gradle/ktlint/testdsl/testDsl.kt | 6 +----- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/KotlinJsPluginTests.kt b/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/KotlinJsPluginTests.kt index 21320f05..170d917b 100644 --- a/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/KotlinJsPluginTests.kt +++ b/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/KotlinJsPluginTests.kt @@ -26,7 +26,7 @@ class KotlinJsPluginTests : AbstractPluginTest() { """ kotlin { - js { + js(IR) { nodejs() } } diff --git a/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/KtlintIdeaPluginTest.kt b/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/KtlintIdeaPluginTest.kt index d0e86d93..513924bb 100644 --- a/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/KtlintIdeaPluginTest.kt +++ b/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/KtlintIdeaPluginTest.kt @@ -24,9 +24,9 @@ class KtlintIdeaPluginTest : AbstractPluginTest() { mavenLocal() gradlePluginPortal() } - + plugins { - id 'org.jetbrains.kotlin.jvm' version '${TestVersions.maxSupportedKotlinPluginVersion}' + id 'org.jetbrains.kotlin.jvm' version '${TestVersions.maxSupportedKotlinPluginVersion()}' id 'org.jlleitschuh.gradle.ktlint-idea' version '${TestVersions.pluginVersion}' } } diff --git a/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/testdsl/testAnnotations.kt b/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/testdsl/testAnnotations.kt index dcde274b..c8385d5c 100644 --- a/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/testdsl/testAnnotations.kt +++ b/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/testdsl/testAnnotations.kt @@ -1,21 +1,28 @@ package org.jlleitschuh.gradle.ktlint.testdsl +import java.io.File +import java.util.stream.Stream +import kotlin.streams.asStream import org.gradle.util.GradleVersion import org.jetbrains.kotlin.utils.addToStdlib.cast import org.jlleitschuh.gradle.ktlint.KtlintBasePlugin import org.junit.jupiter.api.extension.ExtensionContext import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.ArgumentsProvider -import java.io.File -import java.util.stream.Stream -import kotlin.streams.asStream object TestVersions { const val minSupportedGradleVersion = KtlintBasePlugin.LOWEST_SUPPORTED_GRADLE_VERSION - const val maxSupportedGradleVersion = "7.6" + const val maxSupportedGradleVersion = "8.0.1" val pluginVersion = File("VERSION_CURRENT.txt").readText().trim() const val minSupportedKotlinPluginVersion = "1.4.32" - const val maxSupportedKotlinPluginVersion = "1.5.31" + + fun maxSupportedKotlinPluginVersion( + gradleVersion: GradleVersion = GradleVersion.version(maxSupportedGradleVersion) + ): String = when (gradleVersion) { + in (GradleVersion.version("6.8.3")..GradleVersion.version(maxSupportedGradleVersion)) -> "1.8.10" + in (GradleVersion.version("6.7.1")..GradleVersion.version("7.1.1")) -> "1.7.21" + else -> minSupportedKotlinPluginVersion + } } @Target(AnnotationTarget.FUNCTION, AnnotationTarget.CLASS) diff --git a/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/testdsl/testDsl.kt b/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/testdsl/testDsl.kt index f0251039..55fa4aed 100644 --- a/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/testdsl/testDsl.kt +++ b/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/testdsl/testDsl.kt @@ -143,11 +143,7 @@ fun defaultProjectSetup(gradleVersion: GradleVersion): (File) -> Unit = projectSetup("jvm", gradleVersion) private val GradleVersion.supportedKotlinVersion - get() = if (this <= GradleVersion.version("6.1.1")) { - TestVersions.minSupportedKotlinPluginVersion - } else { - TestVersions.maxSupportedKotlinPluginVersion - } + get() = TestVersions.maxSupportedKotlinPluginVersion(this) fun projectSetup( kotlinPluginType: String,