Skip to content

Commit

Permalink
Updated all the dependencies to latest versions I could find (#13)
Browse files Browse the repository at this point in the history
* Updated all the dependencies to latest versions I could find

* Moved @file:OptIn below copyright
  • Loading branch information
toddobryan authored Mar 16, 2024
1 parent 2e7e037 commit dbafcdd
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 24 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions kotlin-ir-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,36 @@
* 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(
defaultString = "Hello, World!",
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))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -42,19 +46,18 @@ fun debug() = "Hello, World!"

fun compile(
sourceFiles: List<SourceFile>,
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)
}

0 comments on commit dbafcdd

Please sign in to comment.