From dbafcdd02b8232caa257364190ed346f69ae9633 Mon Sep 17 00:00:00 2001 From: Todd O'Bryan Date: Sat, 16 Mar 2024 09:41:54 -0700 Subject: [PATCH] Updated all the dependencies to latest versions I could find (#13) * Updated all the dependencies to latest versions I could find * Moved @file:OptIn below copyright --- .editorconfig | 1 + build.gradle.kts | 8 ++++---- kotlin-ir-plugin/build.gradle.kts | 6 +++--- .../template/TemplateCommandLineProcessor.kt | 3 +++ ...istrar.kt => TemplateCompilerRegistrar.kt} | 20 +++++++++---------- .../kotlin/com/bnorm/template/IrPluginTest.kt | 17 +++++++++------- 6 files changed, 31 insertions(+), 24 deletions(-) rename kotlin-ir-plugin/src/main/kotlin/com/bnorm/template/{TemplateComponentRegistrar.kt => TemplateCompilerRegistrar.kt} (73%) diff --git a/.editorconfig b/.editorconfig index 03e22d6..7578448 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,5 +5,6 @@ end_of_line = lf insert_final_newline = true [*.{kt,kts}] +ktlint_code_style = intellij_idea indent_style = space indent_size = 2 diff --git a/build.gradle.kts b/build.gradle.kts index c1f2732..4126cc4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,10 +3,10 @@ buildscript { } plugins { - kotlin("jvm") version "1.7.10" apply false - id("org.jetbrains.dokka") version "1.7.10" apply false - id("com.gradle.plugin-publish") version "1.0.0" apply false - id("com.github.gmazzo.buildconfig") version "3.1.0" apply false + kotlin("jvm") version "1.9.22" apply false + id("org.jetbrains.dokka") version "1.9.10" apply false + id("com.gradle.plugin-publish") version "1.2.1" apply false + id("com.github.gmazzo.buildconfig") version "5.3.5" apply false } allprojects { diff --git a/kotlin-ir-plugin/build.gradle.kts b/kotlin-ir-plugin/build.gradle.kts index 917ce98..5cda1e8 100644 --- a/kotlin-ir-plugin/build.gradle.kts +++ b/kotlin-ir-plugin/build.gradle.kts @@ -7,12 +7,12 @@ plugins { dependencies { compileOnly("org.jetbrains.kotlin:kotlin-compiler-embeddable") - kapt("com.google.auto.service:auto-service:1.0.1") - compileOnly("com.google.auto.service:auto-service-annotations:1.0.1") + kapt("com.google.auto.service:auto-service:1.1.1") + compileOnly("com.google.auto.service:auto-service-annotations:1.1.1") testImplementation(kotlin("test-junit")) testImplementation("org.jetbrains.kotlin:kotlin-compiler-embeddable") - testImplementation("com.github.tschuchortdev:kotlin-compile-testing:1.4.9") + testImplementation("dev.zacsweers.kctfork:core:0.4.0") } buildConfig { diff --git a/kotlin-ir-plugin/src/main/kotlin/com/bnorm/template/TemplateCommandLineProcessor.kt b/kotlin-ir-plugin/src/main/kotlin/com/bnorm/template/TemplateCommandLineProcessor.kt index 862ca4b..f34a59e 100644 --- a/kotlin-ir-plugin/src/main/kotlin/com/bnorm/template/TemplateCommandLineProcessor.kt +++ b/kotlin-ir-plugin/src/main/kotlin/com/bnorm/template/TemplateCommandLineProcessor.kt @@ -14,12 +14,15 @@ * limitations under the License. */ +@file:OptIn(ExperimentalCompilerApi::class) + package com.bnorm.template import com.google.auto.service.AutoService import org.jetbrains.kotlin.compiler.plugin.AbstractCliOption import org.jetbrains.kotlin.compiler.plugin.CliOption import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor +import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi import org.jetbrains.kotlin.config.CompilerConfiguration import org.jetbrains.kotlin.config.CompilerConfigurationKey diff --git a/kotlin-ir-plugin/src/main/kotlin/com/bnorm/template/TemplateComponentRegistrar.kt b/kotlin-ir-plugin/src/main/kotlin/com/bnorm/template/TemplateCompilerRegistrar.kt similarity index 73% rename from kotlin-ir-plugin/src/main/kotlin/com/bnorm/template/TemplateComponentRegistrar.kt rename to kotlin-ir-plugin/src/main/kotlin/com/bnorm/template/TemplateCompilerRegistrar.kt index a3897b6..da00b24 100644 --- a/kotlin-ir-plugin/src/main/kotlin/com/bnorm/template/TemplateComponentRegistrar.kt +++ b/kotlin-ir-plugin/src/main/kotlin/com/bnorm/template/TemplateCompilerRegistrar.kt @@ -14,21 +14,24 @@ * limitations under the License. */ +@file:OptIn(ExperimentalCompilerApi::class) + package com.bnorm.template import com.google.auto.service.AutoService import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys import org.jetbrains.kotlin.cli.common.messages.MessageCollector -import org.jetbrains.kotlin.com.intellij.mock.MockProject -import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar +import org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar +import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi import org.jetbrains.kotlin.config.CompilerConfiguration -@AutoService(ComponentRegistrar::class) -class TemplateComponentRegistrar( +@AutoService(CompilerPluginRegistrar::class) +class TemplateCompilerRegistrar( private val defaultString: String, private val defaultFile: String, -) : ComponentRegistrar { +) : CompilerPluginRegistrar() { + override val supportsK2 = true @Suppress("unused") // Used by service loader constructor() : this( @@ -36,14 +39,11 @@ class TemplateComponentRegistrar( defaultFile = "file.txt" ) - override fun registerProjectComponents( - project: MockProject, - configuration: CompilerConfiguration - ) { + override fun ExtensionStorage.registerExtensions(configuration: CompilerConfiguration) { val messageCollector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE) val string = configuration.get(TemplateCommandLineProcessor.ARG_STRING, defaultString) val file = configuration.get(TemplateCommandLineProcessor.ARG_FILE, defaultFile) - IrGenerationExtension.registerExtension(project, TemplateIrGenerationExtension(messageCollector, string, file)) + IrGenerationExtension.registerExtension(TemplateIrGenerationExtension(messageCollector, string, file)) } } diff --git a/kotlin-ir-plugin/src/test/kotlin/com/bnorm/template/IrPluginTest.kt b/kotlin-ir-plugin/src/test/kotlin/com/bnorm/template/IrPluginTest.kt index fecb147..1dd1cdb 100644 --- a/kotlin-ir-plugin/src/test/kotlin/com/bnorm/template/IrPluginTest.kt +++ b/kotlin-ir-plugin/src/test/kotlin/com/bnorm/template/IrPluginTest.kt @@ -14,12 +14,16 @@ * limitations under the License. */ +@file:OptIn(ExperimentalCompilerApi::class) + package com.bnorm.template +import com.tschuchort.compiletesting.JvmCompilationResult import com.tschuchort.compiletesting.KotlinCompilation import com.tschuchort.compiletesting.SourceFile +import org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar import kotlin.test.assertEquals -import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar +import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi import org.junit.Test class IrPluginTest { @@ -42,19 +46,18 @@ fun debug() = "Hello, World!" fun compile( sourceFiles: List, - plugin: ComponentRegistrar = TemplateComponentRegistrar(), -): KotlinCompilation.Result { + plugin: CompilerPluginRegistrar = TemplateCompilerRegistrar(), +): JvmCompilationResult { return KotlinCompilation().apply { sources = sourceFiles - useIR = true - compilerPlugins = listOf(plugin) + compilerPluginRegistrars = listOf(plugin) inheritClassPath = true }.compile() } fun compile( sourceFile: SourceFile, - plugin: ComponentRegistrar = TemplateComponentRegistrar(), -): KotlinCompilation.Result { + plugin: CompilerPluginRegistrar = TemplateCompilerRegistrar(), +): JvmCompilationResult { return compile(listOf(sourceFile), plugin) }