From 43f0796c54a179bfd0e0e94c7c79128771bbbf2a Mon Sep 17 00:00:00 2001 From: Matthew Haughton <3flex@users.noreply.github.com> Date: Thu, 6 Apr 2023 11:49:00 +1000 Subject: [PATCH] Update to Kotlin 1.8.20 (#5893) * Workaround for https://github.com/JetBrains/kotlin/commit/b50a803b6fa0fc23732de12b3b881c10dc8cc3a8 * Kotlin 1.8.20 * Don't explicitly enable new JVM incremental compilation This is enabled by default in Kotlin 1.8.20 * Remove stdlib from Gradle plugin's classpath --- build-logic/src/main/kotlin/module.gradle.kts | 4 ---- detekt-compiler-plugin/gradle.properties | 2 +- detekt-gradle-plugin/build.gradle.kts | 6 +++++- detekt-gradle-plugin/gradle.properties | 1 + detekt-rules-libraries/build.gradle.kts | 1 + detekt-rules-ruleauthors/build.gradle.kts | 1 + .../kotlin/io/github/detekt/test/utils/KtTestCompiler.kt | 5 +++++ gradle.properties | 1 - gradle/libs.versions.toml | 2 +- 9 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 detekt-gradle-plugin/gradle.properties diff --git a/build-logic/src/main/kotlin/module.gradle.kts b/build-logic/src/main/kotlin/module.gradle.kts index b367f4dcac0..d11cb244c59 100644 --- a/build-logic/src/main/kotlin/module.gradle.kts +++ b/build-logic/src/main/kotlin/module.gradle.kts @@ -62,10 +62,6 @@ testing { } } -dependencies { - compileOnly(kotlin("stdlib-jdk8")) -} - java { withSourcesJar() withJavadocJar() diff --git a/detekt-compiler-plugin/gradle.properties b/detekt-compiler-plugin/gradle.properties index a1e902a4343..f5c6f83714d 100644 --- a/detekt-compiler-plugin/gradle.properties +++ b/detekt-compiler-plugin/gradle.properties @@ -1,4 +1,4 @@ -kotlinCompilerChecksum=4c3fa7bc1bb9ef3058a2319d8bcc3b7196079f88e92fdcd8d304a46f4b6b5787 +kotlinCompilerChecksum=10df74c3c6e2eafd4c7a5572352d37cbe41774996e42de627023cb4c82b50ae4 kotlin.code.style=official systemProp.sonar.host.url=http://localhost:9000 diff --git a/detekt-gradle-plugin/build.gradle.kts b/detekt-gradle-plugin/build.gradle.kts index 70775cd0508..113f2fbe1ab 100644 --- a/detekt-gradle-plugin/build.gradle.kts +++ b/detekt-gradle-plugin/build.gradle.kts @@ -43,6 +43,7 @@ testing { useJUnitJupiter(libs.versions.junit.get()) dependencies { + compileOnly("org.jetbrains:annotations:13.0") implementation(libs.assertj) implementation(testFixtures(project(":"))) } @@ -68,7 +69,10 @@ dependencies { compileOnly(libs.android.gradle.minSupported) compileOnly(libs.kotlin.gradle) compileOnly(libs.kotlin.gradlePluginApi) - implementation(libs.sarif4k) + testFixturesCompileOnly("org.jetbrains:annotations:13.0") + implementation(libs.sarif4k) { + exclude("org.jetbrains.kotlin") + } compileOnly("io.gitlab.arturbosch.detekt:detekt-cli:1.22.0") testKitRuntimeOnly(libs.kotlin.gradle) diff --git a/detekt-gradle-plugin/gradle.properties b/detekt-gradle-plugin/gradle.properties new file mode 100644 index 00000000000..0d6aa7b61fb --- /dev/null +++ b/detekt-gradle-plugin/gradle.properties @@ -0,0 +1 @@ +kotlin.stdlib.default.dependency=false diff --git a/detekt-rules-libraries/build.gradle.kts b/detekt-rules-libraries/build.gradle.kts index d3bc4007c57..0f33a58611c 100644 --- a/detekt-rules-libraries/build.gradle.kts +++ b/detekt-rules-libraries/build.gradle.kts @@ -3,6 +3,7 @@ plugins { } dependencies { + compileOnly(kotlin("stdlib-jdk8")) compileOnly(projects.detektApi) testImplementation(projects.detektTest) testImplementation(libs.assertj) diff --git a/detekt-rules-ruleauthors/build.gradle.kts b/detekt-rules-ruleauthors/build.gradle.kts index ee69d514396..5da7be0301a 100644 --- a/detekt-rules-ruleauthors/build.gradle.kts +++ b/detekt-rules-ruleauthors/build.gradle.kts @@ -3,6 +3,7 @@ plugins { } dependencies { + compileOnly(kotlin("stdlib-jdk8")) compileOnly(projects.detektApi) testImplementation(projects.detektTest) testImplementation(libs.assertj) diff --git a/detekt-test-utils/src/main/kotlin/io/github/detekt/test/utils/KtTestCompiler.kt b/detekt-test-utils/src/main/kotlin/io/github/detekt/test/utils/KtTestCompiler.kt index 37a37911225..fa524da3773 100644 --- a/detekt-test-utils/src/main/kotlin/io/github/detekt/test/utils/KtTestCompiler.kt +++ b/detekt-test-utils/src/main/kotlin/io/github/detekt/test/utils/KtTestCompiler.kt @@ -16,6 +16,7 @@ import org.jetbrains.kotlin.com.intellij.openapi.util.Disposer import org.jetbrains.kotlin.com.intellij.openapi.util.text.StringUtilRt import org.jetbrains.kotlin.config.CommonConfigurationKeys import org.jetbrains.kotlin.config.CompilerConfiguration +import org.jetbrains.kotlin.config.JVMConfigurationKeys import org.jetbrains.kotlin.psi.KtFile import java.io.File import java.nio.file.Path @@ -52,6 +53,10 @@ internal object KtTestCompiler : KtCompiler() { configuration.put(CommonConfigurationKeys.MODULE_NAME, "test_module") configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE) + if (System.getenv("JAVA_HOME") != null) { + configuration.put(JVMConfigurationKeys.JDK_HOME, File(System.getenv("JAVA_HOME"))) + } + // Get the runtime locations of both the stdlib and kotlinx coroutines core jars and pass // to the compiler so it's available to generate the BindingContext for rules under test. configuration.apply { diff --git a/gradle.properties b/gradle.properties index 41f609b0467..337bd819295 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,4 @@ kotlin.code.style=official -kotlin.incremental.useClasspathSnapshot=true kotlin.daemon.useFallbackStrategy=false org.gradle.parallel=true org.gradle.caching=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index bc012ef3af4..923d35e2f19 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] dokka = "1.8.10" jacoco = "0.8.9" -kotlin = "1.8.10" +kotlin = "1.8.20" ktlint = "0.48.2" junit = "5.9.2" contester = "0.2.0"