chore: support for kotlin 2.x#147
Conversation
Signed-off-by: Sam Gammon <sam@elide.ventures>
- chore: changes to support kotlin `2.x` - chore: changes to support newer serialization plugin - chore: upgrade gradle → `8.6` - chore: upgrade detekt → latest Signed-off-by: Sam Gammon <sam@elide.ventures>
|
|
||
| remoteUrl = | ||
| URL("https://github.com/JetBrains-Research/reflekt/tree/master/using-embedded-kotlin/${this@subprojects.name}/src/main/kotlin/") | ||
| uri("https://github.com/JetBrains-Research/reflekt/tree/master/using-embedded-kotlin/${this@subprojects.name}/src/main/kotlin/").toURL() |
There was a problem hiding this comment.
Fixes a build warning, I can roll it back if you want
| kotlin { | ||
| compilerOptions { | ||
| apiVersion = ktTarget | ||
| languageVersion = ktTarget | ||
| freeCompilerArgs = freeCompilerArgs.get().plus(ktCompilerArgs) | ||
| } | ||
| } | ||
|
|
||
| afterEvaluate { | ||
| tasks.withType(KotlinCompile::class).configureEach { | ||
| kotlinOptions { | ||
| apiVersion = ktTarget.version | ||
| languageVersion = ktTarget.version | ||
| freeCompilerArgs = freeCompilerArgs.plus(ktCompilerArgs) | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Unnecessary duplication?
There was a problem hiding this comment.
Hopefully this can replace the duplication in other modules, but I can roll back this project if you'd rather express these flags in each module.
| @@ -1,2 +1,4 @@ | |||
| kotlin.code.style=official | |||
| org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m | |||
| org.gradle.caching=true | |||
There was a problem hiding this comment.
It's useless for local builds. Build cache is good for CI, because on CI, you can grab the caches after build to reuse them in the next run.
| org.gradle.caching=true |
| kotlin.code.style=official | ||
| org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m | ||
| org.gradle.caching=true | ||
| org.gradle.parallel=true |
There was a problem hiding this comment.
It's true by default.
| org.gradle.parallel=true |
| import org.jetbrains.kotlin.gradle.dsl.KotlinVersion | ||
| import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
|
||
| val libs = the<LibrariesForLibs>() |
| includeBuild("using-embedded-kotlin") | ||
|
|
||
| enableFeaturePreview("STABLE_CONFIGURATION_CACHE") | ||
| enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") |
There was a problem hiding this comment.
Feature preview enabled, but never used.
| include(":reflekt-plugin") | ||
| includeBuild("using-embedded-kotlin") | ||
|
|
||
| enableFeaturePreview("STABLE_CONFIGURATION_CACHE") |
There was a problem hiding this comment.
Please explain how this preview helps.
There was a problem hiding this comment.
I added this because it improves the configuration cache experience, at least for me; doesn't need to be in this PR, though. I'll remove it.
|
|
||
| dependencies { | ||
| implementation(libs.plugin.kotlin) | ||
| implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) |
There was a problem hiding this comment.
What is going on here?
There was a problem hiding this comment.
This is a fix from the Gradle team which makes Version Catalog symbols visible within the precompiled build script (the convention plugin). I can add a comment which explains it because otherwise it's pretty mysterious.
There was a problem hiding this comment.
Any reason why can't this logic be just in a couple of build files? buildSrc and convention plugins were avoided for clarity, preventing mix-up of classpathes and build performance.
There was a problem hiding this comment.
I've structured this as a single convention plugin, so that compiler flags are consistent across modules. To use Kotlin 2.0.0 beta, we'll need to pass at least some compiler flags to solve OptIns and allow unstable outputs.
I don't think the flags need to be kept after Kotlin 2.0.0 release, so I can add them to each module.
There was a problem hiding this comment.
Please make it so. If we had more modules, of course, a convention plugin would be necessary.
| "-Xskip-prerelease-check", | ||
| "-Xsuppress-version-warnings", | ||
| "-Xallow-unstable-dependencies", | ||
| "-opt-in=org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI", |
There was a problem hiding this comment.
Why do we need all these compiler keys now, considering that everything was fine?
There was a problem hiding this comment.
Some of these are needed for Kotlin 2.0, in particular the final two. I will check if the first two are needed.
|
@CommanderTvis thank you for the quick review, sorry for the mess 😅 we are trying this downstream to see if it works as expected. |
|
With regard to the I remember now. This Stacktracejava.lang.NoSuchMethodError: 'void com.intellij.openapi.util.io.NioFiles.deleteRecursively(java.nio.file.Path)' at org.jetbrains.kotlin.test.services.impl.TemporaryDirectoryManagerImpl.cleanupTemporaryDirectories(TemporaryDirectoryManagerImpl.kt:45) at org.jetbrains.kotlin.test.TestRunner.runTest(TestRunner.kt:32) at org.jetbrains.kotlin.test.TestRunner.runTest$default(TestRunner.kt:27) at org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerTest.runTest(AbstractKotlinCompilerTest.kt:88) at org.jetbrains.reflekt.plugin.compiler.runners.general.ReflektWithLibraryTestGenerated$Classes$Classes_1.testClasses_1(ReflektWithLibraryTestGenerated.java:46) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at java.base/java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:194) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.tryRemoveAndExec(ForkJoinPool.java:1351) at java.base/java.util.concurrent.ForkJoinTask.awaitDone(ForkJoinTask.java:422) at java.base/java.util.concurrent.ForkJoinTask.join(ForkJoinTask.java:651) at java.base/java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:194) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.tryRemoveAndExec(ForkJoinPool.java:1351) at java.base/java.util.concurrent.ForkJoinTask.awaitDone(ForkJoinTask.java:422) at java.base/java.util.concurrent.ForkJoinTask.join(ForkJoinTask.java:651) at java.base/java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:194) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.tryRemoveAndExec(ForkJoinPool.java:1351) at java.base/java.util.concurrent.ForkJoinTask.awaitDone(ForkJoinTask.java:422) at java.base/java.util.concurrent.ForkJoinTask.join(ForkJoinTask.java:651) at java.base/java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:194) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188) It was being suppressed because it's deleting temporary files, otherwise the tests seem to pass. |
Summary
Initial changes to support Kotlin
2.x.xbeta.Changelog
2.x8.6