-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: support for kotlin 2.x
#147
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Sam Gammon <[email protected]>
- 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 <[email protected]>
@@ -102,7 +102,7 @@ subprojects { | |||
localDirectory = [email protected]("src/main/kotlin") | |||
|
|||
remoteUrl = | |||
URL("https://github.com/JetBrains-Research/reflekt/tree/master/using-embedded-kotlin/${[email protected]}/src/main/kotlin/") | |||
uri("https://github.com/JetBrains-Research/reflekt/tree/master/using-embedded-kotlin/${[email protected]}/src/main/kotlin/").toURL() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it relevant? :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary duplication?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
@@ -1,2 +1,4 @@ | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused val
.
includeBuild("using-embedded-kotlin") | ||
|
||
enableFeaturePreview("STABLE_CONFIGURATION_CACHE") | ||
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feature preview enabled, but never used.
includeBuild("using-embedded-kotlin") | ||
|
||
enableFeaturePreview("STABLE_CONFIGURATION_CACHE") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please explain how this preview helps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is going on here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need all these compiler keys now, considering that everything was fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.x
beta.Changelog
2.x
8.6